@Override public boolean drainBuild(FluidStack fluidStack, boolean realDrain) { for (Tank tank : fluidTanks) { if (tank.getFluidType() == fluidStack.getFluid()) { return tank.getFluidAmount() >= fluidStack.amount && tank.drain(fluidStack.amount, realDrain).amount > 0; } } return false; }
@Override public boolean canFill(ForgeDirection from, Fluid fluid) { boolean emptyAvailable = false; for (Tank tank : fluidTanks) { Fluid type = tank.getFluidType(); if (type == fluid) { return !tank.isFull(); } else if (!emptyAvailable) { emptyAvailable = tank.isEmpty(); } } return emptyAvailable; }
@Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { Fluid fluid = resource.getFluid(); Tank emptyTank = null; for (Tank tank : fluidTanks) { Fluid type = tank.getFluidType(); if (type == fluid) { int used = tank.fill(resource, doFill); if (used > 0 && doFill) { sendNetworkUpdate(); } return used; } else if (emptyTank == null && tank.isEmpty()) { emptyTank = tank; } } if (emptyTank != null) { int used = emptyTank.fill(resource, doFill); if (used > 0 && doFill) { sendNetworkUpdate(); } return used; } return 0; }