use of blusunrize.immersiveengineering.api.crafting.RefineryRecipe in project ImmersiveEngineering by BluSunrize.
the class Refinery method addRecipe.
@ZenMethod
public static void addRecipe(ILiquidStack output, ILiquidStack input0, ILiquidStack input1, int energy) {
FluidStack fOut = CraftTweakerHelper.toFluidStack(output);
FluidStack fIn0 = CraftTweakerHelper.toFluidStack(input0);
FluidStack fIn1 = CraftTweakerHelper.toFluidStack(input1);
if (fOut == null || fIn0 == null || fIn1 == null)
return;
RefineryRecipe r = new RefineryRecipe(fOut, fIn0, fIn1, energy);
MineTweakerAPI.apply(new Add(r));
}
use of blusunrize.immersiveengineering.api.crafting.RefineryRecipe in project ImmersiveEngineering by BluSunrize.
the class TileEntityRefinery method update.
@Override
public void update() {
super.update();
if (worldObj.isRemote || isDummy())
return;
boolean update = false;
if (energyStorage.getEnergyStored() > 0 && processQueue.size() < this.getProcessQueueMaxLength()) {
if (tanks[0].getFluidAmount() > 0 || tanks[1].getFluidAmount() > 0) {
RefineryRecipe recipe = RefineryRecipe.findRecipe(tanks[0].getFluid(), tanks[1].getFluid());
if (recipe != null) {
MultiblockProcessInMachine<RefineryRecipe> process = new MultiblockProcessInMachine(recipe).setInputTanks((tanks[0].getFluidAmount() > 0 && tanks[1].getFluidAmount() > 0) ? new int[] { 0, 1 } : tanks[0].getFluidAmount() > 0 ? new int[] { 0 } : new int[] { 1 });
if (this.addProcessToQueue(process, true)) {
this.addProcessToQueue(process, false);
update = true;
}
}
}
}
if (this.tanks[2].getFluidAmount() > 0) {
ItemStack filledContainer = Utils.fillFluidContainer(tanks[2], inventory[4], inventory[5], null);
if (filledContainer != null) {
if (inventory[5] != null && OreDictionary.itemMatches(inventory[5], filledContainer, true))
inventory[5].stackSize += filledContainer.stackSize;
else if (inventory[5] == null)
inventory[5] = filledContainer.copy();
if (--inventory[4].stackSize <= 0)
inventory[4] = null;
update = true;
}
if (this.tanks[2].getFluidAmount() > 0) {
FluidStack out = Utils.copyFluidStackWithAmount(this.tanks[2].getFluid(), Math.min(this.tanks[2].getFluidAmount(), 80), false);
BlockPos outputPos = this.getPos().add(0, -1, 0).offset(facing.getOpposite());
IFluidHandler output = FluidUtil.getFluidHandler(worldObj, outputPos, facing);
if (output != null) {
int accepted = output.fill(out, false);
if (accepted > 0) {
int drained = output.fill(Utils.copyFluidStackWithAmount(out, Math.min(out.amount, accepted), false), true);
this.tanks[2].drain(drained, true);
update = true;
}
}
}
}
ItemStack emptyContainer = Utils.drainFluidContainer(tanks[0], inventory[0], inventory[1], null);
if (emptyContainer != null && emptyContainer.stackSize > 0) {
if (inventory[1] != null && OreDictionary.itemMatches(inventory[1], emptyContainer, true))
inventory[1].stackSize += emptyContainer.stackSize;
else if (inventory[1] == null)
inventory[1] = emptyContainer.copy();
if (--inventory[0].stackSize <= 0)
inventory[0] = null;
update = true;
}
emptyContainer = Utils.drainFluidContainer(tanks[1], inventory[2], inventory[3], null);
if (emptyContainer != null && emptyContainer.stackSize > 0) {
if (inventory[3] != null && OreDictionary.itemMatches(inventory[3], emptyContainer, true))
inventory[3].stackSize += emptyContainer.stackSize;
else if (inventory[3] == null)
inventory[3] = emptyContainer.copy();
if (--inventory[2].stackSize <= 0)
inventory[2] = null;
update = true;
}
if (update) {
this.markDirty();
this.markContainingBlockForUpdate(null);
}
}
Aggregations