Skip to content

Commit

Permalink
Fixed Lumber Axe Exploit
Browse files Browse the repository at this point in the history
  • Loading branch information
auxiliary-character committed Jun 19, 2015
1 parent a7405a3 commit df02597
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions src/main/java/tconstruct/items/tools/LumberAxe.java
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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++)
{
Expand Down Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit df02597

Please sign in to comment.