use of me.haydenb.assemblylinemachines.registry.Utils.IFluidHandlerBypass in project assemblylinemachines by HaydenBelanger.
the class BathCrafting method assemble.
@Override
public ItemStack assemble(Container inv) {
if (inv instanceof IMachineDataBridge) {
IMachineDataBridge data = (IMachineDataBridge) inv;
IFluidHandler handler = data.getCraftingFluidHandler(Optional.empty());
BiFunction<Integer, FluidAction, FluidStack> drain = handler instanceof IFluidHandlerBypass ? (i, a) -> ((IFluidHandlerBypass) handler).drainBypassRestrictions(i, a) : (i, a) -> handler.drain(i, a);
if (handler == null || handler.getFluidInTank(0).getFluid() != fluid.getAssocFluid() || drain.apply(percent.getMB(), FluidAction.SIMULATE).getAmount() != percent.getMB())
return ItemStack.EMPTY;
int rand = RAND.nextInt(9) * data.getUpgradeAmount(Upgrades.MACHINE_CONSERVATION);
int cons = percent.getMB();
if (rand > 21) {
cons = 0;
} else if (rand > 15) {
cons = (int) Math.round((double) cons * 0.25d);
} else if (rand > 10) {
cons = (int) Math.round((double) cons * 0.5d);
} else if (rand > 5) {
cons = (int) Math.round((double) cons * 0.75d);
}
drain.apply(cons, FluidAction.EXECUTE);
inv.getItem(1).shrink(1);
inv.getItem(2).shrink(1);
data.setCycles((float) stirs * 3.6f);
}
return this.output.copy();
}
Aggregations