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);
}
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;
}
}
}
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);
}
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);
}
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());
}
}
Aggregations