From aec4bfc17da835fa5e4ced42a6c49cd6ba513208 Mon Sep 17 00:00:00 2001 From: brad-c Date: Sat, 7 Sep 2013 20:49:17 +0800 Subject: [PATCH] #44 Liquids in reservoir and conduits not always rendering correctly. --- .../conduit/liquid/LiquidConduitNetwork.java | 3 +++ .../machine/reservoir/ReservoirRenderer.java | 15 ++++++++--- .../machine/reservoir/TileReservoir.java | 25 +++++++++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/common/crazypants/enderio/conduit/liquid/LiquidConduitNetwork.java b/common/crazypants/enderio/conduit/liquid/LiquidConduitNetwork.java index 90f4bbaf..e8289172 100644 --- a/common/crazypants/enderio/conduit/liquid/LiquidConduitNetwork.java +++ b/common/crazypants/enderio/conduit/liquid/LiquidConduitNetwork.java @@ -163,6 +163,9 @@ public class LiquidConduitNetwork extends AbstractConduitNetwork for (ILiquidConduit con : conduits) { if (con.getTank().getFluidAmount() < 10) { toEmpty.add(con); + } else { + //some of the conduits have fluid left in them so don't do the final drain yet + return result; } } diff --git a/common/crazypants/enderio/machine/reservoir/ReservoirRenderer.java b/common/crazypants/enderio/machine/reservoir/ReservoirRenderer.java index cd4057b1..beb03075 100644 --- a/common/crazypants/enderio/machine/reservoir/ReservoirRenderer.java +++ b/common/crazypants/enderio/machine/reservoir/ReservoirRenderer.java @@ -15,6 +15,7 @@ import crazypants.render.BoundingBox; import crazypants.render.CubeRenderer; import crazypants.render.RenderUtil; import crazypants.vecmath.Vector3d; +import crazypants.vecmath.Vector3f; public class ReservoirRenderer extends TileEntitySpecialRenderer { @@ -35,10 +36,12 @@ public class ReservoirRenderer extends TileEntitySpecialRenderer { public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { TileReservoir res = (TileReservoir) tileentity; + if(res.haveRendered(tileentity.worldObj.getTotalWorldTime(), f)) { + return; + } float fullness = res.getFilledRatio(); - if ((res.isMultiblock() && !res.isMaster() && (fullness >= 0 || res.isAutoEject())) || (!res.isMultiblock() && - fullness <= 0)) { + if(fullness <= 0 && !res.isAutoEject()) { return; } @@ -53,11 +56,14 @@ public class ReservoirRenderer extends TileEntitySpecialRenderer { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glTranslatef((float) x, (float) y, (float) z); + + Vector3f offset = res.getOffsetFromController(); + + GL11.glTranslatef((float) x + offset.x, (float) y + offset.y, (float) z + offset.z); BoundingBox bb = res.getLiquidRenderBounds(); - if (res.isMultiblock() && res.isAutoEject()) { + if(res.isAutoEject()) { // switch RenderUtil.bindBlockTexture(); @@ -164,4 +170,5 @@ public class ReservoirRenderer extends TileEntitySpecialRenderer { } return tex; } + } diff --git a/common/crazypants/enderio/machine/reservoir/TileReservoir.java b/common/crazypants/enderio/machine/reservoir/TileReservoir.java index 333de57e..6acfbc92 100644 --- a/common/crazypants/enderio/machine/reservoir/TileReservoir.java +++ b/common/crazypants/enderio/machine/reservoir/TileReservoir.java @@ -22,6 +22,7 @@ import crazypants.enderio.ModObject; import crazypants.enderio.PacketHandler; import crazypants.render.BoundingBox; import crazypants.util.BlockCoord; +import crazypants.vecmath.Vector3f; public class TileReservoir extends TileEntity implements IFluidHandler { @@ -624,4 +625,28 @@ public class TileReservoir extends TileEntity implements IFluidHandler { return res; } + public Vector3f getOffsetFromController() { + if(!isMultiblock()) { + return new Vector3f(); + } + BlockCoord masterBC = multiblock[0]; + BlockCoord myBC = new BlockCoord(xCoord, yCoord, zCoord); + return new Vector3f(masterBC.x - myBC.x, masterBC.y - myBC.y, masterBC.z - myBC.z); + } + + long lastRenderTick; + float lastRenderPartialTick; + + public boolean haveRendered(long renderTick, float renderPartialTick) { + TileReservoir c = getController(); + if(c.lastRenderTick == renderTick && renderPartialTick == c.lastRenderPartialTick) { + return true; + } + + c.lastRenderTick = renderTick; + c.lastRenderPartialTick = renderPartialTick; + + return false; + } + }