use of blusunrize.immersiveengineering.api.crafting.MixerRecipe in project ImmersiveEngineering by BluSunrize.
the class Mixer method addRecipe.
@ZenMethod
public static void addRecipe(ILiquidStack output, ILiquidStack fluidInput, IIngredient[] itemInputs, int energy) {
Object[] adds = null;
if (itemInputs != null) {
adds = new Object[itemInputs.length];
for (int i = 0; i < itemInputs.length; i++) adds[i] = CraftTweakerHelper.toObject(itemInputs[i]);
}
MixerRecipe r = new MixerRecipe(CraftTweakerHelper.toFluidStack(output), CraftTweakerHelper.toFluidStack(fluidInput), adds, energy);
MineTweakerAPI.apply(new Add(r));
}
use of blusunrize.immersiveengineering.api.crafting.MixerRecipe in project ImmersiveEngineering by BluSunrize.
the class TileEntityMixer method update.
@Override
public void update() {
super.update();
if (isDummy() || isRSDisabled())
return;
if (worldObj.isRemote) {
if (shouldRenderAsActive()) {
if (worldObj.rand.nextInt(8) == 0) {
FluidStack fs = !tank.fluids.isEmpty() ? tank.fluids.get(0) : null;
if (fs != null) {
float amount = tank.getFluidAmount() / (float) tank.getCapacity() * 1.125f;
Vec3d partPos = new Vec3d(getPos().getX() + .5f + facing.getFrontOffsetX() * .5f + (mirrored ? facing.rotateYCCW() : facing.rotateY()).getFrontOffsetX() * .5f, getPos().getY() - .0625f + amount, getPos().getZ() + .5f + facing.getFrontOffsetZ() * .5f + (mirrored ? facing.rotateYCCW() : facing.rotateY()).getFrontOffsetZ() * .5f);
float r = worldObj.rand.nextFloat() * .8125f;
float angleRad = (float) Math.toRadians(animation_agitator);
partPos = partPos.addVector(r * Math.cos(angleRad), 0, r * Math.sin(angleRad));
if (worldObj.rand.nextBoolean())
ImmersiveEngineering.proxy.spawnBubbleFX(worldObj, fs, partPos.xCoord, partPos.yCoord, partPos.zCoord, 0, 0, 0);
else
ImmersiveEngineering.proxy.spawnFluidSplashFX(worldObj, fs, partPos.xCoord, partPos.yCoord, partPos.zCoord, 0, 0, 0);
}
}
animation_agitator = (animation_agitator + 9) % 360;
}
} else {
boolean update = false;
boolean foundRecipe = false;
if (energyStorage.getEnergyStored() > 0 && processQueue.size() < this.getProcessQueueMaxLength()) {
int tankAmount = tank.getFluidAmount();
if (tankAmount > 0) {
Set<Integer> usedInvSlots = new HashSet<Integer>();
for (MultiblockProcess<MixerRecipe> process : processQueue) if (process instanceof MultiblockProcessInMachine)
for (int i : ((MultiblockProcessInMachine<MixerRecipe>) process).inputSlots) usedInvSlots.add(i);
ItemStack[] components = new ItemStack[this.inventory.length];
for (int i = 0; i < components.length; i++) if (!usedInvSlots.contains(i))
components[i] = inventory[i];
for (FluidStack fs : tank.fluids) {
MixerRecipe recipe = MixerRecipe.findRecipe(fs, components);
if (recipe != null) {
foundRecipe = true;
MultiblockProcessInMachine process = new MultiblockProcessMixer(recipe, recipe.getUsedSlots(fs, components)).setInputTanks(0);
if (this.addProcessToQueue(process, true)) {
this.addProcessToQueue(process, false);
update = true;
}
}
}
}
}
if (this.tank.getFluidTypes() > 1 || !foundRecipe || outputAll) {
BlockPos outputPos = this.getPos().down().offset(facing.getOpposite(), 2);
IFluidHandler output = FluidUtil.getFluidHandler(worldObj, outputPos, facing);
if (output != null) {
if (!outputAll) {
FluidStack inTank = this.tank.getFluid();
if (inTank != null) {
FluidStack out = Utils.copyFluidStackWithAmount(inTank, Math.min(inTank.amount, 80), false);
int accepted = output.fill(out, false);
if (accepted > 0) {
int drained = output.fill(Utils.copyFluidStackWithAmount(out, Math.min(out.amount, accepted), false), true);
this.tank.drain(drained, true);
update = true;
}
}
} else {
int totalOut = 0;
Iterator<FluidStack> it = this.tank.fluids.iterator();
while (it.hasNext()) {
FluidStack fs = it.next();
if (fs != null) {
FluidStack out = Utils.copyFluidStackWithAmount(fs, Math.min(fs.amount, 80 - totalOut), false);
int accepted = output.fill(out, false);
if (accepted > 0) {
int drained = output.fill(Utils.copyFluidStackWithAmount(out, Math.min(out.amount, accepted), false), true);
MultiFluidTank.drain(drained, fs, it, true);
totalOut += drained;
update = true;
}
if (totalOut >= 80)
break;
}
}
}
}
}
if (update) {
this.markDirty();
this.markContainingBlockForUpdate(null);
}
}
}
Aggregations