Search in sources :

Example 1 with DimletType

use of mcjty.rftools.items.dimlets.DimletType in project RFTools by McJty.

the class DimletTypeItemSorter method getDimletType.

private static DimletType getDimletType(Pair<ItemStack, Integer> object) {
    DimletType type = null;
    if (object.getKey().getItem() == DimletSetup.knownDimlet) {
        DimletKey key = KnownDimletConfiguration.getDimletKey(object.getKey(), null);
        type = key.getType();
    }
    return type;
}
Also used : DimletType(mcjty.rftools.items.dimlets.DimletType) DimletKey(mcjty.rftools.items.dimlets.DimletKey)

Example 2 with DimletType

use of mcjty.rftools.items.dimlets.DimletType in project RFTools by McJty.

the class DimletTypeItemSorter method isSameGroup.

@Override
public boolean isSameGroup(Pair<ItemStack, Integer> o1, Pair<ItemStack, Integer> o2) {
    DimletType type1 = getDimletType(o1);
    DimletType type2 = getDimletType(o2);
    return type1 == type2;
}
Also used : DimletType(mcjty.rftools.items.dimlets.DimletType)

Example 3 with DimletType

use of mcjty.rftools.items.dimlets.DimletType in project RFTools 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 && slot.getStack() != null && slot.getStack().stackSize > 0) {
            ItemStack stack = slot.getStack();
            DimletKey key = KnownDimletConfiguration.getDimletKey(stack, Minecraft.getMinecraft().theWorld);
            if (key.getType() == DimletType.DIMLET_TERRAIN) {
                cntTerrain++;
                terrainType = DimletObjectMapping.idToTerrainType.get(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.idToSpecialType.get(key) == SpecialType.SPECIAL_OWNER) {
                cntOwner++;
            }
        }
    }
    if (cntOwner > 1) {
        tooltips.add("Using more then one owner dimlet is not useful!");
    }
    if (DimletConfiguration.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 && slot.getStack() != null && slot.getStack().stackSize > 0) {
            ItemStack stack = slot.getStack();
            DimletKey key = KnownDimletConfiguration.getDimletKey(stack, Minecraft.getMinecraft().theWorld);
            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.idToTerrainType.get(key) == TerrainType.TERRAIN_VOID && !modifiersForType.isEmpty()) {
                        tooltips.add("VOID terrain cannot use modifiers");
                    }
                } else if (type == DimletType.DIMLET_FEATURE) {
                    FeatureType featureType = DimletObjectMapping.idToFeatureType.get(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.idToControllerType.get(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");
}
Also used : FeatureType(mcjty.rftools.dimension.world.types.FeatureType) ArrayList(java.util.ArrayList) TerrainType(mcjty.rftools.dimension.world.types.TerrainType) DimletKey(mcjty.rftools.items.dimlets.DimletKey) ControllerType(mcjty.rftools.dimension.world.types.ControllerType) Counter(mcjty.lib.varia.Counter) DimletType(mcjty.rftools.items.dimlets.DimletType) Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 4 with DimletType

use of mcjty.rftools.items.dimlets.DimletType in project RFTools by McJty.

the class GuiDimletFilter method initGui.

@Override
public void initGui() {
    super.initGui();
    Panel toplevel = new Panel(mc, this).setBackground(iconLocation).setLayout(new PositionalLayout());
    int[] inputMode = tileEntity.getInputMode();
    int[] minRarity = tileEntity.getMinRarity();
    int[] maxRarity = tileEntity.getMaxRarity();
    int[] craftableI = tileEntity.getCraftable();
    DimletType[] dimletTypes = tileEntity.getTypes();
    for (ForgeDirection direction : ForgeDirection.values()) {
        if (!ForgeDirection.UNKNOWN.equals(direction)) {
            final int side = direction.ordinal();
            Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout().setSpacing(2).setHorizontalMargin(2)).setLayoutHint(new PositionalLayout.PositionalHint(18, 21 + side * 13, 190, 12));
            ImageChoiceLabel choiceLabel = new ImageChoiceLabel(mc, this).setDesiredWidth(12).setDesiredHeight(12).addChoice("0", "Disabled", iconGuiElements, 160, 0).addChoice("1", "Input", iconGuiElements, 96, 16).addChoice("2", "Output", iconGuiElements, 80, 16);
            bits[side] = choiceLabel;
            choiceLabel.setCurrentChoice(inputMode[side]);
            choiceLabel.addChoiceEvent(new ChoiceEvent() {

                @Override
                public void choiceChanged(Widget parent, String newChoice) {
                    changeMode(side);
                }
            });
            Label minLabel = new Label(mc, this).setText("R:");
            minText[side] = new TextField(mc, this).setDesiredHeight(12).setDesiredWidth(20).addTextEvent(new TextEvent() {

                @Override
                public void textChanged(Widget parent, String newText) {
                    setMinimumRarity(side);
                }
            });
            minText[side].setText(Integer.toString(minRarity[side]));
            maxText[side] = new TextField(mc, this).setDesiredHeight(12).setDesiredWidth(20).addTextEvent(new TextEvent() {

                @Override
                public void textChanged(Widget parent, String newText) {
                    setMaximumRarity(side);
                }
            });
            maxText[side].setText(Integer.toString(maxRarity[side]));
            types[side] = new ChoiceLabel(mc, this).setDesiredHeight(12).setDesiredWidth(83).setTooltips("Filter based on type", "of the dimlet");
            types[side].addChoices("*");
            for (DimletType type : DimletType.values()) {
                types[side].addChoices(type.dimletType.getName());
            }
            if (dimletTypes[side] == null) {
                types[side].setChoice("*");
            } else {
                types[side].setChoice(dimletTypes[side].dimletType.getName());
            }
            types[side].addChoiceEvent(new ChoiceEvent() {

                @Override
                public void choiceChanged(Widget parent, String newChoice) {
                    setType(side);
                }
            });
            craftable[side] = new ChoiceLabel(mc, this).setDesiredHeight(12).setDesiredWidth(26).setTooltips("Filter based on craftability", "of the dimlet");
            craftable[side].addChoices("*", "Y", "N");
            if (craftableI[side] == DimletFilterTileEntity.CRAFTABLE_DONTCARE) {
                craftable[side].setChoice("*");
            } else if (craftableI[side] == DimletFilterTileEntity.CRAFTABLE_YES) {
                craftable[side].setChoice("Y");
            } else {
                craftable[side].setChoice("N");
            }
            craftable[side].addChoiceEvent(new ChoiceEvent() {

                @Override
                public void choiceChanged(Widget parent, String newChoice) {
                    setCraftable(side);
                }
            });
            panel.addChild(choiceLabel).addChild(minLabel).addChild(minText[side]).addChild(maxText[side]).addChild(types[side]).addChild(craftable[side]);
            toplevel.addChild(panel);
        }
    }
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
    window = new Window(this, toplevel);
}
Also used : Window(mcjty.lib.gui.Window) TextEvent(mcjty.lib.gui.events.TextEvent) ChoiceEvent(mcjty.lib.gui.events.ChoiceEvent) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Label(mcjty.lib.gui.widgets.Label) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Panel(mcjty.lib.gui.widgets.Panel) DimletType(mcjty.rftools.items.dimlets.DimletType) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) TextField(mcjty.lib.gui.widgets.TextField)

Example 5 with DimletType

use of mcjty.rftools.items.dimlets.DimletType in project RFTools by McJty.

the class DimletTypeItemSorter method compareTypes.

public static int compareTypes(Pair<ItemStack, Integer> o1, Pair<ItemStack, Integer> o2) {
    DimletType type1 = getDimletType(o1);
    DimletType type2 = getDimletType(o2);
    if (type1 == null) {
        if (type2 == null) {
            return NameItemSorter.compareNames(o1, o2);
        } else {
            return -1;
        }
    }
    if (type2 == null) {
        return 1;
    }
    if (type1 == type2) {
        return NameItemSorter.compareNames(o1, o2);
    }
    return type1.compareTo(type2);
}
Also used : DimletType(mcjty.rftools.items.dimlets.DimletType)

Aggregations

DimletType (mcjty.rftools.items.dimlets.DimletType)5 DimletKey (mcjty.rftools.items.dimlets.DimletKey)2 ArrayList (java.util.ArrayList)1 Window (mcjty.lib.gui.Window)1 ChoiceEvent (mcjty.lib.gui.events.ChoiceEvent)1 TextEvent (mcjty.lib.gui.events.TextEvent)1 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)1 PositionalLayout (mcjty.lib.gui.layout.PositionalLayout)1 Label (mcjty.lib.gui.widgets.Label)1 Panel (mcjty.lib.gui.widgets.Panel)1 TextField (mcjty.lib.gui.widgets.TextField)1 Counter (mcjty.lib.varia.Counter)1 ControllerType (mcjty.rftools.dimension.world.types.ControllerType)1 FeatureType (mcjty.rftools.dimension.world.types.FeatureType)1 TerrainType (mcjty.rftools.dimension.world.types.TerrainType)1 Slot (net.minecraft.inventory.Slot)1 ItemStack (net.minecraft.item.ItemStack)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1