public boolean use( ItemStack[] inventory, int index, FluidTank fluidTank, GasTank gasTank, boolean deplete) { if (meets(new PressurizedInput(inventory[index], fluidTank.getFluid(), gasTank.getGas()))) { if (deplete) { inventory[index] = StackUtils.subtract(inventory[index], theSolid); fluidTank.drain(theFluid.amount, true); gasTank.draw(theGas.amount, true); } return true; } return false; }
@Override public void onUpdate() { if (worldObj.isRemote) { Mekanism.proxy.registerSound(this); if (updateDelay > 0) { updateDelay--; if (updateDelay == 0 && clientActive != isActive) { isActive = clientActive; MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } } } if (!worldObj.isRemote) { if (updateDelay > 0) { updateDelay--; if (updateDelay == 0 && clientActive != isActive) { Mekanism.packetHandler.sendToAll( new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList()))); } } ChargeUtils.discharge(3, this); if (inventory[0] != null && (injectTank.getGas() == null || injectTank.getStored() < injectTank.getMaxGas())) { injectTank.receive( GasTransmission.removeGas( inventory[0], GasRegistry.getGas("sulfuricAcid"), injectTank.getNeeded()), true); } if (inventory[2] != null && outputTank.getGas() != null) { outputTank.draw(GasTransmission.addGas(inventory[2], outputTank.getGas()), true); } boolean changed = false; if (canOperate() && getEnergy() >= MekanismUtils.getEnergyPerTick(this, ENERGY_USAGE) && injectTank.getStored() >= INJECT_USAGE && MekanismUtils.canFunction(this)) { setActive(true); setEnergy(getEnergy() - MekanismUtils.getEnergyPerTick(this, ENERGY_USAGE)); if (operatingTicks < MekanismUtils.getTicks(this, TICKS_REQUIRED)) { operatingTicks++; injectTank.draw(INJECT_USAGE, true); } else { GasStack stack = RecipeHandler.getItemToGasOutput( inventory[1], true, Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get()); outputTank.receive(stack, true); injectTank.draw(INJECT_USAGE, true); operatingTicks = 0; if (inventory[1].stackSize <= 0) { inventory[1] = null; } markDirty(); } } else { if (prevEnergy >= getEnergy()) { changed = true; setActive(false); } } if (changed && !canOperate()) { operatingTicks = 0; } prevEnergy = getEnergy(); if (outputTank.getGas() != null) { GasStack toSend = new GasStack(outputTank.getGas().getGas(), Math.min(outputTank.getStored(), gasOutput)); TileEntity tileEntity = Coord4D.get(this).getFromSide(MekanismUtils.getRight(facing)).getTileEntity(worldObj); if (tileEntity instanceof IGasHandler) { if (((IGasHandler) tileEntity) .canReceiveGas( MekanismUtils.getRight(facing).getOpposite(), outputTank.getGas().getGas())) { outputTank.draw( ((IGasHandler) tileEntity) .receiveGas(MekanismUtils.getRight(facing).getOpposite(), toSend), true); } } } } }
@Override public GasStack drawGas(EnumFacing side, int amount, boolean doTransfer) { return collectedGas.draw(amount, doTransfer); }