Search in sources :

Example 11 with MachineUtil

use of binnie.core.machines.MachineUtil 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 12 with MachineUtil

use of binnie.core.machines.MachineUtil in project Binnie by ForestryMC.

the class LumbermillLogic method onFinishTask.

@Override
protected void onFinishTask() {
    MachineUtil util = getUtil();
    final ItemStack logStack = util.getStack(LumbermillMachine.SLOT_LOG);
    final ItemStack result = LumbermillRecipeManager.getPlankProduct(logStack, util.getWorld());
    if (result.isEmpty()) {
        return;
    }
    util.addStack(LumbermillMachine.SLOT_PLANKS, result);
    util.addStack(LumbermillMachine.SLOT_SAWDUST, ExtraTreeItems.SAWDUST.get(2));
    util.addStack(LumbermillMachine.SLOT_BARK, ExtraTreeItems.Bark.get(2));
    util.decreaseStack(LumbermillMachine.SLOT_LOG, 1);
}
Also used : MachineUtil(binnie.core.machines.MachineUtil) ItemStack(net.minecraft.item.ItemStack)

Aggregations

MachineUtil (binnie.core.machines.MachineUtil)12 ItemStack (net.minecraft.item.ItemStack)9 IMachine (binnie.core.machines.IMachine)3 ErrorState (binnie.core.machines.errors.ErrorState)3 ComponentInventorySlots (binnie.core.machines.inventory.ComponentInventorySlots)2 ComponentInventoryTransfer (binnie.core.machines.inventory.ComponentInventoryTransfer)2 InventorySlot (binnie.core.machines.inventory.InventorySlot)2 SlotValidator (binnie.core.machines.inventory.SlotValidator)2 ComponentPowerReceptor (binnie.core.machines.power.ComponentPowerReceptor)2 ComponentGeneticGUI (binnie.genetics.machine.ComponentGeneticGUI)2 Random (java.util.Random)2 Gene (binnie.core.genetics.Gene)1 ComponentTankContainer (binnie.core.machines.inventory.ComponentTankContainer)1 IChargedSlots (binnie.core.machines.inventory.IChargedSlots)1 IAllele (forestry.api.genetics.IAllele)1 IChromosomeType (forestry.api.genetics.IChromosomeType)1 IGenome (forestry.api.genetics.IGenome)1 IIndividual (forestry.api.genetics.IIndividual)1 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)1 ArrayList (java.util.ArrayList)1