Search in sources :

Example 6 with MachineUtil

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

the class InoculatorLogic method onFinishTask.

@Override
protected void onFinishTask() {
    super.onFinishTask();
    MachineUtil util = this.getUtil();
    final ItemStack serum = util.getStack(Inoculator.SLOT_SERUM_VIAL);
    final ItemStack target = util.getStack(Inoculator.SLOT_TARGET);
    ItemStack applied = applySerum(target, serum);
    util.setStack(Inoculator.SLOT_TARGET, applied);
    util.damageItem(serum, Inoculator.SLOT_SERUM_VIAL, 1);
}
Also used : MachineUtil(binnie.core.machines.MachineUtil) ItemStack(net.minecraft.item.ItemStack)

Example 7 with MachineUtil

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

the class AcclimatiserLogic method attemptAcclimatisation.

protected void attemptAcclimatisation() {
    final List<ItemStack> acclms = new ArrayList<>();
    final MachineUtil machineUtil = getUtil();
    ItemStack target = machineUtil.getStack(Acclimatiser.SLOT_TARGET);
    if (target.isEmpty()) {
        return;
    }
    for (final ItemStack s : machineUtil.getNonEmptyStacks(Acclimatiser.SLOT_ACCLIMATISER)) {
        if (Acclimatiser.canAcclimatise(target, s)) {
            acclms.add(s);
        }
    }
    final ItemStack acc = acclms.get(machineUtil.getRandom().nextInt(acclms.size()));
    final ItemStack acclimed = Acclimatiser.acclimatise(target, acc);
    machineUtil.setStack(Acclimatiser.SLOT_TARGET, acclimed);
    for (final int i : Acclimatiser.SLOT_ACCLIMATISER) {
        ItemStack stack = machineUtil.getStack(i);
        if (!stack.isEmpty() && stack.isItemEqual(acc)) {
            machineUtil.decreaseStack(i, 1);
            break;
        }
    }
}
Also used : MachineUtil(binnie.core.machines.MachineUtil) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 8 with MachineUtil

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

the class GenepoolLogic method onFinishTask.

@Override
protected void onFinishTask() {
    super.onFinishTask();
    MachineUtil util = getUtil();
    ItemStack individual = util.getStack(Genepool.SLOT_BEE);
    int amount = getDNAAmount(individual);
    util.fillTank(Genepool.TANK_DNA, GeneticLiquid.RawDNA.get(amount));
    util.deleteStack(Genepool.SLOT_BEE);
}
Also used : MachineUtil(binnie.core.machines.MachineUtil) ItemStack(net.minecraft.item.ItemStack)

Example 9 with MachineUtil

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

the class GenepoolLogic method onTickTask.

@Override
protected void onTickTask() {
    MachineUtil util = getUtil();
    ItemStack individual = util.getStack(Genepool.SLOT_BEE);
    this.ethanolDrain += getDNAAmount(individual) * 1.2f * this.getProgressPerTick() / 100.0f;
    if (this.ethanolDrain >= 1.0f) {
        util.drainTank(Genepool.TANK_ETHANOL, 1);
        --this.ethanolDrain;
    }
    IChargedSlots chargedSlots = this.getMachine().getInterface(IChargedSlots.class);
    chargedSlots.alterCharge(Genepool.SLOT_ENZYME, -ENZYME_PER_PROCESS * this.getProgressPerTick() / 100.0f);
}
Also used : MachineUtil(binnie.core.machines.MachineUtil) IChargedSlots(binnie.core.machines.inventory.IChargedSlots) ItemStack(net.minecraft.item.ItemStack)

Example 10 with MachineUtil

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

the class ControlSequencerProgress method onUpdateClient.

@Override
public void onUpdateClient() {
    super.onUpdateClient();
    IMachine machine = Machine.getMachine(Window.get(this).getInventory());
    MachineUtil machineUtil = machine.getMachineUtil();
    ItemStack stackTarget = machineUtil.getStack(Sequencer.SLOT_TARGET);
    if (stackTarget.isEmpty()) {
        this.textControl.setValue("");
    } else {
        Random rand = new Random(stackTarget.getDisplayName().length());
        StringBuilder text = new StringBuilder();
        for (int i = 0; i < 65; ++i) {
            int k = rand.nextInt(4);
            String code = CODES[k];
            if (rand.nextFloat() < this.progress) {
                text.append(TextFormatting.RESET).append(COLORS[k]).append(TextFormatting.BOLD).append(code);
            } else {
                text.append(TextFormatting.RESET).append(TextFormatting.GRAY).append(TextFormatting.OBFUSCATED).append(TextFormatting.BOLD).append(code);
            }
        }
        this.textControl.setValue(text.toString());
    }
}
Also used : MachineUtil(binnie.core.machines.MachineUtil) IMachine(binnie.core.machines.IMachine) Random(java.util.Random) 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