Search in sources :

Example 1 with SlotValidator

use of binnie.core.machines.inventory.SlotValidator in project Binnie by ForestryMC.

the class ControlSlot method getHelpTooltip.

@Override
public void getHelpTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) {
    final InventorySlot slot = this.getInventorySlot();
    if (slot != null) {
        tooltip.add(slot.getName());
        if (tooltipFlag.isAdvanced()) {
            Collection<EnumFacing> inputSides = slot.getInputSides();
            if (inputSides.size() > 0) {
                tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.side.insert", MachineSide.asString(inputSides)));
            }
            Collection<EnumFacing> outputSides = slot.getOutputSides();
            if (outputSides.size() > 0) {
                tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.side.extract", MachineSide.asString(outputSides)));
            }
            if (slot.isReadOnly()) {
                tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.slot.pickup.only"));
            }
        }
    } else if (this.slot.inventory instanceof WindowInventory) {
        if (tooltipFlag.isAdvanced()) {
            final SlotValidator s = ((WindowInventory) this.slot.inventory).getValidator(this.slot.getSlotIndex());
            tooltip.add("Accepts: " + ((s == null) ? "Any Item" : s.getTooltip()));
        }
    } else if (this.slot.inventory instanceof InventoryPlayer) {
        if (tooltipFlag.isAdvanced()) {
            tooltip.add(I18N.localise(ModId.CORE, "gui.slot.player.inventory"));
        }
    }
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) WindowInventory(binnie.core.gui.minecraft.WindowInventory) EnumFacing(net.minecraft.util.EnumFacing) InventorySlot(binnie.core.machines.inventory.InventorySlot) SlotValidator(binnie.core.machines.inventory.SlotValidator)

Example 2 with SlotValidator

use of binnie.core.machines.inventory.SlotValidator in project Binnie by ForestryMC.

the class ControlSlot method onRenderBackground.

@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
    CraftGUI.RENDER.texture(CraftGUITexture.SLOT, Point.ZERO);
    final InventorySlot islot = this.getInventorySlot();
    if (islot != null) {
        SlotValidator validator = islot.getValidator();
        if (validator != null) {
            final TextureAtlasSprite icon = validator.getIcon(!islot.getInputSides().isEmpty());
            if (icon != null && icon != Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite()) {
                GlStateManager.enableBlend();
                RenderUtil.drawSprite(new Point(1, 1), icon);
                GlStateManager.disableBlend();
            }
        }
    }
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) InventorySlot(binnie.core.machines.inventory.InventorySlot) Point(binnie.core.gui.geometry.Point) SlotValidator(binnie.core.machines.inventory.SlotValidator) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with SlotValidator

use of binnie.core.machines.inventory.SlotValidator in project Binnie by ForestryMC.

the class PackageInoculator method createMachine.

@Override
public void createMachine(final Machine machine) {
    new ComponentGeneticGUI(machine, GeneticsGUI.INOCULATOR);
    final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
    InventorySlot slotSerumVial = inventory.addSlot(Inoculator.SLOT_SERUM_VIAL, getSlotRL("serum.active"));
    slotSerumVial.forbidInteraction();
    slotSerumVial.setReadOnly();
    final SlotValidator serumValid = new SerumSlotValidator();
    slotSerumVial.setValidator(serumValid);
    for (InventorySlot slot : inventory.addSlotArray(Inoculator.SLOT_SERUM_RESERVE, getSlotRL("serum.input"))) {
        slot.setValidator(serumValid);
        slot.forbidExtraction();
    }
    for (InventorySlot slot : inventory.addSlotArray(Inoculator.SLOT_SERUM_EXPENDED, getSlotRL("serum.output"))) {
        slot.setValidator(serumValid);
        slot.setReadOnly();
    }
    for (InventorySlot slot : inventory.addSlotArray(Inoculator.SLOT_RESERVE, getSlotRL("input"))) {
        slot.forbidExtraction();
        slot.setValidator(new ValidatorIndividualInoculate());
    }
    InventorySlot slotTarget = inventory.addSlot(Inoculator.SLOT_TARGET, getSlotRL("process"));
    slotTarget.setValidator(new ValidatorIndividualInoculate());
    slotTarget.setReadOnly();
    slotTarget.forbidInteraction();
    for (final InventorySlot slot : inventory.addSlotArray(Inoculator.SLOT_FINISHED, getSlotRL("output"))) {
        slot.setReadOnly();
        slot.forbidInsertion();
        slot.setValidator(new ValidatorIndividualInoculate());
    }
    final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
    transfer.addRestock(Inoculator.SLOT_RESERVE, 9, 1);
    transfer.addRestock(Inoculator.SLOT_SERUM_RESERVE, 0);
    transfer.addStorage(Inoculator.SLOT_SERUM_VIAL, Inoculator.SLOT_SERUM_EXPENDED, (stack) -> Engineering.getCharges(stack) == 0);
    transfer.addStorage(Inoculator.SLOT_TARGET, Inoculator.SLOT_FINISHED, (stack) -> {
        if (!stack.isEmpty()) {
            IMachine machine1 = transfer.getMachine();
            MachineUtil machineUtil = machine1.getMachineUtil();
            if (!machineUtil.getStack(Inoculator.SLOT_SERUM_VIAL).isEmpty() && machine1.getInterface(InoculatorLogic.class).isValidSerum() != null) {
                return true;
            }
        }
        return false;
    });
    new ComponentPowerReceptor(machine, 15000);
    new InoculatorLogic(machine);
    new InoculatorFX(machine);
    new ComponentTankContainer(machine).addTank(Inoculator.TANK_VEKTOR, "input", 1000).setValidator(new BacteriaVectorTankValidator());
}
Also used : MachineUtil(binnie.core.machines.MachineUtil) IMachine(binnie.core.machines.IMachine) ComponentInventorySlots(binnie.core.machines.inventory.ComponentInventorySlots) InventorySlot(binnie.core.machines.inventory.InventorySlot) ComponentGeneticGUI(binnie.genetics.machine.ComponentGeneticGUI) ComponentInventoryTransfer(binnie.core.machines.inventory.ComponentInventoryTransfer) ComponentTankContainer(binnie.core.machines.inventory.ComponentTankContainer) SlotValidator(binnie.core.machines.inventory.SlotValidator) ComponentPowerReceptor(binnie.core.machines.power.ComponentPowerReceptor)

Example 4 with SlotValidator

use of binnie.core.machines.inventory.SlotValidator in project Binnie by ForestryMC.

the class PackageSplicer method createMachine.

@Override
public void createMachine(final Machine machine) {
    new ComponentGeneticGUI(machine, GeneticsGUI.SPLICER);
    final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
    InventorySlot slotSerumVial = inventory.addSlot(Splicer.SLOT_SERUM_VIAL, getSlotRL("serum.active"));
    slotSerumVial.forbidInteraction();
    slotSerumVial.setReadOnly();
    final SlotValidator serumValid = new SerumSlotValidator();
    slotSerumVial.setValidator(serumValid);
    for (InventorySlot slot : inventory.addSlotArray(Splicer.SLOT_SERUM_RESERVE, getSlotRL("serum.input"))) {
        slot.setValidator(serumValid);
        slot.forbidExtraction();
    }
    for (InventorySlot slot : inventory.addSlotArray(Splicer.SLOT_SERUM_EXPENDED, getSlotRL("serum.output"))) {
        slot.setValidator(serumValid);
        slot.setReadOnly();
    }
    for (InventorySlot slot : inventory.addSlotArray(Splicer.SLOT_RESERVE, getSlotRL("input"))) {
        slot.forbidExtraction();
        slot.setValidator(new ValidatorIndividualInoculate());
    }
    InventorySlot slotTarget = inventory.addSlot(Splicer.SLOT_TARGET, getSlotRL("process"));
    slotTarget.setValidator(new ValidatorIndividualInoculate());
    slotTarget.setReadOnly();
    slotTarget.forbidInteraction();
    for (InventorySlot slot : inventory.addSlotArray(Splicer.SLOT_FINISHED, getSlotRL("output"))) {
        slot.setReadOnly();
        slot.forbidInsertion();
        slot.setValidator(new ValidatorIndividualInoculate());
    }
    final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
    transfer.addRestock(Splicer.SLOT_RESERVE, Splicer.SLOT_TARGET, 1);
    transfer.addRestock(Splicer.SLOT_SERUM_RESERVE, Splicer.SLOT_SERUM_VIAL);
    transfer.addStorage(Splicer.SLOT_SERUM_VIAL, Splicer.SLOT_SERUM_EXPENDED, (stack) -> Engineering.getCharges(stack) == 0);
    transfer.addStorage(Splicer.SLOT_TARGET, Splicer.SLOT_FINISHED, (stack) -> {
        if (!stack.isEmpty()) {
            IMachine machine1 = transfer.getMachine();
            MachineUtil machineUtil = machine1.getMachineUtil();
            if (!machineUtil.getStack(Splicer.SLOT_SERUM_VIAL).isEmpty() && machine1.getInterface(SplicerLogic.class).isValidSerum() != null) {
                return true;
            }
        }
        return false;
    });
    new ComponentPowerReceptor(machine, 20000);
    new SplicerLogic(machine);
    new SplicerFX(machine);
}
Also used : MachineUtil(binnie.core.machines.MachineUtil) IMachine(binnie.core.machines.IMachine) ComponentInventorySlots(binnie.core.machines.inventory.ComponentInventorySlots) InventorySlot(binnie.core.machines.inventory.InventorySlot) SlotValidator(binnie.core.machines.inventory.SlotValidator) ComponentGeneticGUI(binnie.genetics.machine.ComponentGeneticGUI) ComponentInventoryTransfer(binnie.core.machines.inventory.ComponentInventoryTransfer) ComponentPowerReceptor(binnie.core.machines.power.ComponentPowerReceptor)

Example 5 with SlotValidator

use of binnie.core.machines.inventory.SlotValidator in project Binnie by ForestryMC.

the class ErrorState method getTooltip.

public String getTooltip(ContainerCraftGUI container) {
    Collection<CustomSlot> slots = getCustomSlots(container);
    Set<Validator<?>> validators = new HashSet<>();
    for (CustomSlot slot : slots) {
        InventorySlot inventorySlot = slot.getInventorySlot();
        if (inventorySlot != null) {
            SlotValidator validator = inventorySlot.getValidator();
            if (validator != null) {
                validators.add(validator);
            }
        }
    }
    return definition.getDescription(validators);
}
Also used : CustomSlot(binnie.core.gui.minecraft.CustomSlot) InventorySlot(binnie.core.machines.inventory.InventorySlot) SlotValidator(binnie.core.machines.inventory.SlotValidator) Validator(binnie.core.machines.inventory.Validator) SlotValidator(binnie.core.machines.inventory.SlotValidator) HashSet(java.util.HashSet)

Aggregations

InventorySlot (binnie.core.machines.inventory.InventorySlot)5 SlotValidator (binnie.core.machines.inventory.SlotValidator)5 IMachine (binnie.core.machines.IMachine)2 MachineUtil (binnie.core.machines.MachineUtil)2 ComponentInventorySlots (binnie.core.machines.inventory.ComponentInventorySlots)2 ComponentInventoryTransfer (binnie.core.machines.inventory.ComponentInventoryTransfer)2 ComponentPowerReceptor (binnie.core.machines.power.ComponentPowerReceptor)2 ComponentGeneticGUI (binnie.genetics.machine.ComponentGeneticGUI)2 Point (binnie.core.gui.geometry.Point)1 CustomSlot (binnie.core.gui.minecraft.CustomSlot)1 WindowInventory (binnie.core.gui.minecraft.WindowInventory)1 ComponentTankContainer (binnie.core.machines.inventory.ComponentTankContainer)1 Validator (binnie.core.machines.inventory.Validator)1 HashSet (java.util.HashSet)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)1 EnumFacing (net.minecraft.util.EnumFacing)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1