From e2dd5a09cb1d5be6966773f9a94b71e904ea4b33 Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Thu, 19 Jun 2014 14:58:23 +0200 Subject: [PATCH] You can now push fluids in through the bottom of a Portable Tank, and it will route to the first empty tank above! --- .../render/tileentity/RenderPortableTank.java | 2 +- .../common/tile/TileEntityPortableTank.java | 26 +++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/main/java/mekanism/client/render/tileentity/RenderPortableTank.java b/src/main/java/mekanism/client/render/tileentity/RenderPortableTank.java index 0ef112533..b30523d4e 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderPortableTank.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderPortableTank.java @@ -135,7 +135,7 @@ public class RenderPortableTank extends TileEntitySpecialRenderer if(fluid.getIcon() != null) { toReturn.minX = 0.3125 + .01; - toReturn.minY = 0.0625 + ((float)i/(float)stages)*0.875 + .01; + toReturn.minY = 0.0625 + ((float)i/(float)stages)*0.875; toReturn.minZ = 0.3125 + .01; toReturn.maxX = 0.6875 - .01; diff --git a/src/main/java/mekanism/common/tile/TileEntityPortableTank.java b/src/main/java/mekanism/common/tile/TileEntityPortableTank.java index f132ea40b..eda0f0222 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPortableTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityPortableTank.java @@ -230,6 +230,23 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements } } + private int pushUp(FluidStack fluid) + { + Coord4D up = Coord4D.get(this).getFromSide(ForgeDirection.UP); + + if(up.getTileEntity(worldObj) instanceof IFluidHandler) + { + IFluidHandler handler = (IFluidHandler)up.getTileEntity(worldObj); + + if(handler.canFill(ForgeDirection.DOWN, fluid.getFluid())) + { + return handler.fill(ForgeDirection.DOWN, fluid, true); + } + } + + return 0; + } + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -409,7 +426,12 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements { int filled = fluidTank.fill(resource, doFill); - if(filled > 0) + if(filled < resource.amount && !isActive) + { + filled += pushUp(new FluidStack(resource.getFluid(), resource.amount-filled)); + } + + if(filled > 0 && from == ForgeDirection.UP) { valve = 20; valveFluid = resource.getFluid(); @@ -446,7 +468,7 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements @Override public boolean canFill(ForgeDirection from, Fluid fluid) { - return from == ForgeDirection.UP && (fluidTank.getFluid() == null || fluidTank.getFluid().getFluid() == fluid); + return (from == ForgeDirection.UP || from == ForgeDirection.DOWN) && (fluidTank.getFluid() == null || fluidTank.getFluid().getFluid() == fluid); } @Override