From 42425e3500faccf7eb69f3f329f1e3b35f34732a Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 3 Jun 2016 16:35:06 -0700 Subject: [PATCH] Fix #1281 Crash when trying to place Forestry tiles above Y=255 --- .../arboriculture/items/ItemBlockPile.java | 18 +++++++++-------- .../core/items/ItemBlockForestry.java | 20 ++++++++++--------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/main/java/forestry/arboriculture/items/ItemBlockPile.java b/src/main/java/forestry/arboriculture/items/ItemBlockPile.java index cf631fa51..736409ed6 100644 --- a/src/main/java/forestry/arboriculture/items/ItemBlockPile.java +++ b/src/main/java/forestry/arboriculture/items/ItemBlockPile.java @@ -73,14 +73,16 @@ public class ItemBlockPile extends ItemBlockForestry { public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) { boolean placed = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState); - if(block == PluginArboriculture.blocks.piles.get(EnumPileType.WOOD)){ - if (block.hasTileEntity(newState)) { - if (stack.hasTagCompound()) { - TilePile tile = TileUtil.getTile(world, pos, TilePile.class); - if (tile != null) { - tile.readFromNBT(stack.getTagCompound()); - tile.setPos(pos); - tile.markDirty(); + if (placed) { + if (block == PluginArboriculture.blocks.piles.get(EnumPileType.WOOD)) { + if (block.hasTileEntity(newState)) { + if (stack.hasTagCompound()) { + TilePile tile = TileUtil.getTile(world, pos, TilePile.class); + if (tile != null) { + tile.readFromNBT(stack.getTagCompound()); + tile.setPos(pos); + tile.markDirty(); + } } } } diff --git a/src/main/java/forestry/core/items/ItemBlockForestry.java b/src/main/java/forestry/core/items/ItemBlockForestry.java index 42e3b7745..0d740c821 100644 --- a/src/main/java/forestry/core/items/ItemBlockForestry.java +++ b/src/main/java/forestry/core/items/ItemBlockForestry.java @@ -58,18 +58,20 @@ public class ItemBlockForestry extends ItemBlock { public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) { boolean placed = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState); - if (block.hasTileEntity(newState)) { - if (stack.getItem() instanceof ItemBlockNBT && stack.hasTagCompound()) { - TileForestry tile = TileUtil.getTile(world, pos, TileForestry.class); - if (tile != null) { - tile.readFromNBT(stack.getTagCompound()); - tile.setPos(pos); + if (placed) { + if (block.hasTileEntity(newState)) { + if (stack.getItem() instanceof ItemBlockNBT && stack.hasTagCompound()) { + TileForestry tile = TileUtil.getTile(world, pos, TileForestry.class); + if (tile != null) { + tile.readFromNBT(stack.getTagCompound()); + tile.setPos(pos); + } } } - } - if (block instanceof BlockBase) { - ((BlockBase) block).rotateAfterPlacement(player, world, pos, side); + if (block instanceof BlockBase) { + ((BlockBase) block).rotateAfterPlacement(player, world, pos, side); + } } return placed;