use of mcjty.rftoolsdim.dimensions.dimlets.types.DimletType in project RFToolsDimensions by McJty.
the class GuiEssencePainter method validateDimlets.
private void validateDimlets() {
List<String> tooltips = new ArrayList<String>();
TerrainType terrainType = null;
int cntTerrain = 0;
int cntBiomes = 0;
int cntController = 0;
int cntOwner = 0;
for (int i = EssencePainterContainer.SLOT_DIMLETS; i < EssencePainterContainer.SLOT_TAB; i++) {
Slot slot = inventorySlots.getSlot(i);
if (slot != null && ItemStackTools.isValid(slot.getStack())) {
ItemStack stack = slot.getStack();
DimletKey key = KnownDimletConfiguration.getDimletKey(stack);
if (key.getType() == DimletType.DIMLET_TERRAIN) {
cntTerrain++;
terrainType = DimletObjectMapping.getTerrain(key);
} else if (key.getType() == DimletType.DIMLET_BIOME) {
cntBiomes++;
} else if (key.getType() == DimletType.DIMLET_CONTROLLER) {
cntController++;
} else if (key.getType() == DimletType.DIMLET_SPECIAL && DimletObjectMapping.getSpecial(key) == SpecialType.SPECIAL_OWNER) {
cntOwner++;
}
}
}
if (cntOwner > 1) {
tooltips.add("Using more then one owner dimlet is not useful!");
}
if (GeneralConfiguration.ownerDimletsNeeded && cntOwner != 1) {
tooltips.add("You cannot make a dimension without an owner dimlet!");
storeButton.setEnabled(false);
}
if (cntTerrain > 1) {
tooltips.add("Using more then one TERRAIN is not useful!");
terrainType = null;
}
if (cntController > 1) {
tooltips.add("Using more then one CONTROLLER is not useful!");
}
List<DimletKey> modifiers = new ArrayList<DimletKey>();
for (int i = EssencePainterContainer.SLOT_DIMLETS; i < EssencePainterContainer.SLOT_TAB; i++) {
Slot slot = inventorySlots.getSlot(i);
if (slot != null && ItemStackTools.isValid(slot.getStack())) {
ItemStack stack = slot.getStack();
DimletKey key = KnownDimletConfiguration.getDimletKey(stack);
DimletType type = key.getType();
if (type.dimletType.isModifier()) {
modifiers.add(key);
} else {
List<DimletKey> modifiersForType = extractModifiersForType(modifiers, type);
if (type == DimletType.DIMLET_TERRAIN) {
if (DimletObjectMapping.getTerrain(key) == TerrainType.TERRAIN_VOID && !modifiersForType.isEmpty()) {
tooltips.add("VOID terrain cannot use modifiers");
}
} else if (type == DimletType.DIMLET_FEATURE) {
FeatureType featureType = DimletObjectMapping.getFeature(key);
Counter<DimletType> modifierAmountUsed = new Counter<DimletType>();
for (DimletKey modifier : modifiersForType) {
modifierAmountUsed.increment(modifier.getType());
}
for (Map.Entry<DimletType, Integer> entry : modifierAmountUsed.entrySet()) {
Integer amountSupported = featureType.getSupportedModifierAmount(entry.getKey());
if (amountSupported == null) {
tooltips.add(shortenName(featureType.name()) + " does not use " + shortenName(entry.getKey().name()) + " modifiers!");
} else if (amountSupported == 1 && entry.getValue() > 1) {
tooltips.add(shortenName(featureType.name()) + " only needs one " + shortenName(entry.getKey().name()) + " modifier!");
}
}
if (terrainType == null && !featureType.supportsAllTerrains()) {
tooltips.add(shortenName(featureType.name()) + " is possibly useless as it does not work on all terrains!");
}
if (terrainType != null && !featureType.isTerrainSupported(terrainType)) {
tooltips.add(shortenName(featureType.name()) + " does not work for terrain " + shortenName(terrainType.name()) + "!");
}
} else if (type == DimletType.DIMLET_CONTROLLER) {
ControllerType controllerType = DimletObjectMapping.getController(key);
int neededBiomes = controllerType.getNeededBiomes();
if (neededBiomes != -1) {
if (cntBiomes > neededBiomes) {
tooltips.add("Too many biomes specified for " + shortenName(controllerType.name()) + "!");
} else if (cntBiomes < neededBiomes) {
tooltips.add("Too few biomes specified for " + shortenName(controllerType.name()) + "!");
}
}
}
}
}
}
if (!modifiers.isEmpty()) {
tooltips.add("There are dangling modifiers in this descriptor");
}
boolean error = true;
if (tooltips.isEmpty()) {
tooltips.add("Everything appears to be alright");
error = false;
}
validateField.setTooltips(tooltips.toArray(new String[tooltips.size()]));
validateField.setColor(error ? 0xFF0000 : 0x008800);
validateField.setText(error ? "Warn" : "Ok");
}
use of mcjty.rftoolsdim.dimensions.dimlets.types.DimletType in project RFToolsDimensions by McJty.
the class GuiDimensionEnscriber method validateDimlets.
private void validateDimlets() {
List<String> tooltips = new ArrayList<String>();
TerrainType terrainType = null;
int cntTerrain = 0;
int cntBiomes = 0;
int cntController = 0;
int cntOwner = 0;
for (int i = DimensionEnscriberContainer.SLOT_DIMLETS; i < DimensionEnscriberContainer.SLOT_TAB; i++) {
Slot slot = inventorySlots.getSlot(i);
if (slot != null && ItemStackTools.isValid(slot.getStack())) {
ItemStack stack = slot.getStack();
DimletKey key = KnownDimletConfiguration.getDimletKey(stack);
if (key.getType() == DimletType.DIMLET_TERRAIN) {
cntTerrain++;
terrainType = DimletObjectMapping.getTerrain(key);
} else if (key.getType() == DimletType.DIMLET_BIOME) {
cntBiomes++;
} else if (key.getType() == DimletType.DIMLET_CONTROLLER) {
cntController++;
} else if (key.getType() == DimletType.DIMLET_SPECIAL && DimletObjectMapping.getSpecial(key) == SpecialType.SPECIAL_OWNER) {
cntOwner++;
}
}
}
if (cntOwner > 1) {
tooltips.add("Using more then one owner dimlet is not useful!");
}
if (GeneralConfiguration.ownerDimletsNeeded && cntOwner != 1) {
tooltips.add("You cannot make a dimension without an owner dimlet!");
storeButton.setEnabled(false);
}
if (cntTerrain > 1) {
tooltips.add("Using more then one TERRAIN is not useful!");
terrainType = null;
}
if (cntController > 1) {
tooltips.add("Using more then one CONTROLLER is not useful!");
}
List<DimletKey> modifiers = new ArrayList<DimletKey>();
for (int i = DimensionEnscriberContainer.SLOT_DIMLETS; i < DimensionEnscriberContainer.SLOT_TAB; i++) {
Slot slot = inventorySlots.getSlot(i);
if (slot != null && ItemStackTools.isValid(slot.getStack())) {
ItemStack stack = slot.getStack();
DimletKey key = KnownDimletConfiguration.getDimletKey(stack);
DimletType type = key.getType();
if (type.dimletType.isModifier()) {
modifiers.add(key);
} else {
List<DimletKey> modifiersForType = extractModifiersForType(modifiers, type);
if (type == DimletType.DIMLET_TERRAIN) {
if (DimletObjectMapping.getTerrain(key) == TerrainType.TERRAIN_VOID && !modifiersForType.isEmpty()) {
tooltips.add("VOID terrain cannot use modifiers");
}
} else if (type == DimletType.DIMLET_FEATURE) {
FeatureType featureType = DimletObjectMapping.getFeature(key);
Counter<DimletType> modifierAmountUsed = new Counter<DimletType>();
for (DimletKey modifier : modifiersForType) {
modifierAmountUsed.increment(modifier.getType());
}
for (Map.Entry<DimletType, Integer> entry : modifierAmountUsed.entrySet()) {
Integer amountSupported = featureType.getSupportedModifierAmount(entry.getKey());
if (amountSupported == null) {
tooltips.add(shortenName(featureType.name()) + " does not use " + shortenName(entry.getKey().name()) + " modifiers!");
} else if (amountSupported == 1 && entry.getValue() > 1) {
tooltips.add(shortenName(featureType.name()) + " only needs one " + shortenName(entry.getKey().name()) + " modifier!");
}
}
if (terrainType == null && !featureType.supportsAllTerrains()) {
tooltips.add(shortenName(featureType.name()) + " is possibly useless as it does not work on all terrains!");
}
if (terrainType != null && !featureType.isTerrainSupported(terrainType)) {
tooltips.add(shortenName(featureType.name()) + " does not work for terrain " + shortenName(terrainType.name()) + "!");
}
} else if (type == DimletType.DIMLET_CONTROLLER) {
ControllerType controllerType = DimletObjectMapping.getController(key);
int neededBiomes = controllerType.getNeededBiomes();
if (neededBiomes != -1) {
if (cntBiomes > neededBiomes) {
tooltips.add("Too many biomes specified for " + shortenName(controllerType.name()) + "!");
} else if (cntBiomes < neededBiomes) {
tooltips.add("Too few biomes specified for " + shortenName(controllerType.name()) + "!");
}
}
}
}
}
}
if (!modifiers.isEmpty()) {
tooltips.add("There are dangling modifiers in this descriptor");
}
boolean error = true;
if (tooltips.isEmpty()) {
tooltips.add("Everything appears to be alright");
error = false;
}
validateField.setTooltips(tooltips.toArray(new String[tooltips.size()]));
validateField.setColor(error ? 0xFF0000 : 0x008800);
validateField.setText(error ? "Warn" : "Ok");
}
use of mcjty.rftoolsdim.dimensions.dimlets.types.DimletType in project RFToolsDimensions by McJty.
the class GuiDimletWorkbench method updateList.
private void updateList() {
if (!listDirty) {
return;
}
listDirty = false;
itemList.removeChildren();
Map<DimletKey, Settings> dimlets = KnownDimletConfiguration.getKnownDimlets();
String filter = searchBar.getText().toLowerCase();
// First remove all dimlets with the same name and also apply the filter already
Map<Pair<DimletType, String>, DimletKey> uniquelyNamedDimlets = new HashMap<>();
for (DimletKey key : dimlets.keySet()) {
String name = KnownDimletConfiguration.getDisplayName(key);
if (dimletMatches(filter, key, name)) {
Pair<DimletType, String> k = Pair.of(key.getType(), name);
if (!uniquelyNamedDimlets.containsKey(k)) {
uniquelyNamedDimlets.put(k, key);
}
}
}
List<DimletKey> keys = new ArrayList<>(uniquelyNamedDimlets.values());
keys.sort((a, b) -> {
int rc = a.getType().compareTo(b.getType());
if (rc == 0) {
return a.getId().compareTo(b.getId());
} else {
return rc;
}
});
keys.stream().forEach(key -> addItemToList(key, itemList));
if (itemList.getFirstSelected() >= itemList.getChildCount()) {
itemList.setFirstSelected(0);
}
}
use of mcjty.rftoolsdim.dimensions.dimlets.types.DimletType in project RFToolsDimensions by McJty.
the class DimensionEditorTileEntity method validateInjectableItemStack.
private ItemStack validateInjectableItemStack() {
ItemStack itemStack = inventoryHelper.getStackInSlot(DimensionEditorContainer.SLOT_INJECTINPUT);
if (ItemStackTools.isEmpty(itemStack)) {
stopInjecting();
return ItemStackTools.getEmptyStack();
}
if (isMatterReceiver(itemStack)) {
return itemStack;
}
if (isTNT(itemStack)) {
return canDeleteDimension(itemStack);
}
DimletKey key = KnownDimletConfiguration.getDimletKey(itemStack);
DimletType type = key.getType();
IDimletType itype = type.dimletType;
if (itype.isInjectable()) {
return itemStack;
} else {
return ItemStackTools.getEmptyStack();
}
}
use of mcjty.rftoolsdim.dimensions.dimlets.types.DimletType in project RFToolsDimensions by McJty.
the class KnownDimletConfiguration method getDimletKey.
public static DimletKey getDimletKey(ItemStack dimletStack) {
DimletType type = DimletType.values()[dimletStack.getItemDamage()];
NBTTagCompound tagCompound = dimletStack.getTagCompound();
if (tagCompound != null && tagCompound.hasKey("dkey")) {
return new DimletKey(type, tagCompound.getString("dkey"));
} else {
return new DimletKey(type, null);
}
}
Aggregations