Advertisement
Guest User

dumpLiquid

a guest
Sep 27th, 2014
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. private void dumpLiquid(World world, int x, int y, int z) {
  2.     for (int i = 2; i < 6; i++) {
  3.         ForgeDirection dir = dirs[i];
  4.         TileEntity te = this.getAdjacentTileEntity(dir);
  5.         if (te instanceof TileEntityPipe) {
  6.             TileEntityPipe p = (TileEntityPipe)te;         
  7.             int dL = tank.getLevel()-p.getFluidLevel();
  8.             if (dL/4 > 0) {
  9.                 p.setFluid(tank.getFluid());
  10.                 p.addFluid(dL/4);
  11.                 tank.removeLiquid(dL/4);
  12.             }
  13.         }
  14.         else if (te instanceof IFluidHandler) {
  15.             IFluidHandler ifl = (IFluidHandler)te;
  16.             if (ifl.canFill(dir.getOpposite(), tank.getFluid())) {
  17.                 int added = ifl.fill(dir.getOpposite(), tank.getFluid(), true);
  18.                 if (added > 0) {
  19.                     tank.removeLiquid(added);
  20.                     if (tank.isEmpty())
  21.                         return;
  22.                 }
  23.             }
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement