Fixed a few issues with picking up tanks

Issues with inf fluid bug
Issues with render crash
This commit is contained in:
Robert 2013-12-06 08:06:07 -05:00
parent 826acc8c0d
commit 9bb6098362
2 changed files with 5 additions and 3 deletions

View file

@ -116,7 +116,7 @@ public class ItemTankRenderer implements IItemRenderer
{ {
cap = liquid.amount; 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.glPopAttrib();
GL11.glPopMatrix(); GL11.glPopMatrix();

View file

@ -53,16 +53,18 @@ public class ItemBlockPipe extends ItemBlock
public static ItemStack getWrenchedItem(World world, Vector3 vec) public static ItemStack getWrenchedItem(World world, Vector3 vec)
{ {
TileEntity entity = vec.getTileEntity(world); 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); 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) if (itemStack.getTagCompound() == null)
{ {
itemStack.setTagCompound(new NBTTagCompound()); itemStack.setTagCompound(new NBTTagCompound());
} }
if (stack != null) if (stack != null)
{ {
((TileEntityTank) entity).drain(ForgeDirection.UNKNOWN, stack.amount, true);
itemStack.getTagCompound().setCompoundTag("fluid", stack.writeToNBT(new NBTTagCompound())); itemStack.getTagCompound().setCompoundTag("fluid", stack.writeToNBT(new NBTTagCompound()));
} }
return itemStack; return itemStack;