From 9bb60983622947e864e816e01deee648b0e8e7be Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 6 Dec 2013 08:06:07 -0500 Subject: [PATCH] Fixed a few issues with picking up tanks Issues with inf fluid bug Issues with render crash --- src/dark/fluid/client/render/ItemTankRenderer.java | 2 +- src/dark/fluid/common/pipes/ItemBlockPipe.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dark/fluid/client/render/ItemTankRenderer.java b/src/dark/fluid/client/render/ItemTankRenderer.java index dc936618c..5c4689a31 100644 --- a/src/dark/fluid/client/render/ItemTankRenderer.java +++ b/src/dark/fluid/client/render/ItemTankRenderer.java @@ -116,7 +116,7 @@ public class ItemTankRenderer implements IItemRenderer { cap = liquid.amount; } - GL11.glCallList(displayList[(int) ((float) liquid.amount / (float) (cap) * (RenderBlockFluid.DISPLAY_STAGES - 1))]); + GL11.glCallList(displayList[(int) Math.min(((float) liquid.amount / (float) (cap) * (RenderBlockFluid.DISPLAY_STAGES - 1)), displayList.length - 1)]); GL11.glPopAttrib(); GL11.glPopMatrix(); diff --git a/src/dark/fluid/common/pipes/ItemBlockPipe.java b/src/dark/fluid/common/pipes/ItemBlockPipe.java index cf69213cf..18f0f3b0d 100644 --- a/src/dark/fluid/common/pipes/ItemBlockPipe.java +++ b/src/dark/fluid/common/pipes/ItemBlockPipe.java @@ -53,16 +53,18 @@ public class ItemBlockPipe extends ItemBlock public static ItemStack getWrenchedItem(World world, Vector3 vec) { TileEntity entity = vec.getTileEntity(world); - if (entity instanceof TileEntityTank) + if (entity instanceof TileEntityTank && ((TileEntityTank) entity).getTankInfo() != null && ((TileEntityTank) entity).getTankInfo()[0] != null) { ItemStack itemStack = new ItemStack(FMRecipeLoader.blockTank); - FluidStack stack = ((TileEntityTank) entity).drain(ForgeDirection.UNKNOWN, Integer.MAX_VALUE, false); + FluidStack stack = ((TileEntityTank) entity).getTankInfo()[0].fluid; + if (itemStack.getTagCompound() == null) { itemStack.setTagCompound(new NBTTagCompound()); } if (stack != null) { + ((TileEntityTank) entity).drain(ForgeDirection.UNKNOWN, stack.amount, true); itemStack.getTagCompound().setCompoundTag("fluid", stack.writeToNBT(new NBTTagCompound())); } return itemStack;