From df0259793e451be88b09fdc754bc6a5bd5e5a785 Mon Sep 17 00:00:00 2001 From: Austin Fuller Date: Fri, 19 Jun 2015 00:29:45 -0500 Subject: [PATCH] Fixed Lumber Axe Exploit This exploit: http://youtu.be/4KW0AwXb1zk --- .../tconstruct/items/tools/LumberAxe.java | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/main/java/tconstruct/items/tools/LumberAxe.java b/src/main/java/tconstruct/items/tools/LumberAxe.java index 2d7cc4c40c7..2da4073ebf6 100644 --- a/src/main/java/tconstruct/items/tools/LumberAxe.java +++ b/src/main/java/tconstruct/items/tools/LumberAxe.java @@ -98,7 +98,7 @@ public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPl if(detectTree(world, x,y,z, wood)) { NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); int meta = world.getBlockMetadata(x, y, z); - breakTree(world, x, y, z, stack, tags, wood, meta, player); + breakTree(world, x, y, z, x, y, z, stack, tags, wood, meta, player); // custom block breaking code, don't call vanilla code return true; } @@ -141,7 +141,7 @@ private boolean detectTree(World world, int x, int y, int z, Block wood) return numLeaves > 3; } - private void breakTree (World world, int x, int y, int z, ItemStack stack, NBTTagCompound tags, Block bID, int meta, EntityPlayer player) + private void breakTree (World world, int x, int y, int z, int xStart, int yStart, int zStart, ItemStack stack, NBTTagCompound tags, Block bID, int meta, EntityPlayer player) { for (int xPos = x - 1; xPos <= x + 1; xPos++) { @@ -173,23 +173,30 @@ private void breakTree (World world, int x, int y, int z, ItemStack stack, NBTTa MinecraftForge.EVENT_BUS.post(event); cancelHarvest = event.isCanceled(); - if (cancelHarvest) - { - breakTree(world, xPos, yPos, zPos, stack, tags, bID, meta, player); - } - else + int xDist = xPos - xStart; + int yDist = yPos - yStart; + int zDist = zPos - zStart; + + if (9*xDist*xDist + yDist*yDist + 9*zDist*zDist < 2500 ) { - if (localBlock == bID && localMeta % 4 == meta % 4) + if (cancelHarvest) { - if (!player.capabilities.isCreativeMode) + breakTree(world, xPos, yPos, zPos, xStart, yStart, zStart, stack, tags, bID, meta, player); + } + else + { + if (localBlock == bID && localMeta % 4 == meta % 4) { - localBlock.harvestBlock(world, player, x,y,z, localMeta); - onBlockDestroyed(stack, world, localBlock, xPos, yPos, zPos, player); + if (!player.capabilities.isCreativeMode) + { + localBlock.harvestBlock(world, player, x,y,z, localMeta); + onBlockDestroyed(stack, world, localBlock, xPos, yPos, zPos, player); + } + + world.setBlockToAir(xPos, yPos, zPos); + if (!world.isRemote) + breakTree(world, xPos, yPos, zPos, xStart, yStart, zStart, stack, tags, bID, meta, player); } - - world.setBlockToAir(xPos, yPos, zPos); - if (!world.isRemote) - breakTree(world, xPos, yPos, zPos, stack, tags, bID, meta, player); } } }