@Override public FluidTankInfo[] getTankInfo(ForgeDirection direction) { FluidTank compositeTank = new FluidTank(tank.getCapacity()); TileTank tile = getBottomTank(); int capacity = tank.getCapacity(); if (tile != null && tile.tank.getFluid() != null) { compositeTank.setFluid(tile.tank.getFluid().copy()); } else { return new FluidTankInfo[] {compositeTank.getInfo()}; } tile = getTankAbove(tile); while (tile != null) { FluidStack liquid = tile.tank.getFluid(); if (liquid == null || liquid.amount == 0) { // NOOP } else if (!compositeTank.getFluid().isFluidEqual(liquid)) { break; } else { compositeTank.getFluid().amount += liquid.amount; } capacity += tile.tank.getCapacity(); tile = getTankAbove(tile); } compositeTank.setCapacity(capacity); return new FluidTankInfo[] {compositeTank.getInfo()}; }
public void moveFluidBelow() { TileTank below = getTankBelow(this); if (below == null) { return; } int used = below.tank.fill(tank.getFluid(), true); if (used > 0) { hasUpdate = true; // not redundant because tank.drain operates on an IFluidTank, not a tile below.hasUpdate = true; // redundant because below.fill sets hasUpdate tank.drain(used, true); } }
/* UPDATING */ @Override public void updateEntity() { if (CoreProxy.proxy.isRenderWorld(worldObj)) return; // Have liquid flow down into tanks below if any. if (tank.getFluid() != null) { moveFluidBelow(); } if (hasUpdate && tracker.markTimeIfDelay(worldObj, 2 * BuildCraftCore.updateFactor)) { sendNetworkUpdate(); hasUpdate = false; } }
@Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { if (resource != null && !resource.isFluidEqual(tank.getFluid())) return null; return drain(from, resource.amount, doDrain); }