Fixed NPE when breaking blocks with undefined HarvestTool

This commit is contained in:
Arthur Uzulin committed 2014-02-15 23:56:44 +11:00
1 parent 87e687d4ad
commit e24b53a26e
2 files changed
+6 -2

No files matched your search

@@ -291,7 +291,7 @@ public class Hammer extends HarvestTool
Block localBlock = world.getBlock(xPos, yPos, zPos);
int localMeta = world.getBlockMetadata(xPos, yPos, zPos);
int hlvl = -1;
if (block.getHarvestTool(meta).equals(this.getHarvestType()))
if (block.getHarvestTool(meta) != null && block.getHarvestTool(meta).equals(this.getHarvestType()))
hlvl = block.getHarvestLevel(meta);
float localHardness = localBlock == null ? Float.MAX_VALUE : localBlock.getBlockHardness(world, xPos, yPos, zPos);
@@ -322,10 +322,12 @@ public class Hammer extends HarvestTool
localBlock.onBlockHarvested(world, xPos, yPos, zPos, localMeta, player);
if (blockHardness > 0f)
onBlockDestroyed(stack, world, localBlock, xPos, yPos, zPos, player);
world.func_147479_m(x, y, z);
}
else
{
WorldHelper.setBlockToAir(world, xPos, yPos, zPos);
world.func_147479_m(x, y, z);
}
}
}
@@ -39,7 +39,7 @@ public abstract class HarvestTool extends ToolCore
{
Block localBlock = world.getBlock(x, y, z);
int localMeta = world.getBlockMetadata(x, y, z);
if (block.getHarvestTool(meta).equals(this.getHarvestType()))
if (block.getHarvestTool(meta) != null && block.getHarvestTool(meta).equals(this.getHarvestType()))
hlvl = block.getHarvestLevel(meta);
int toolLevel = tags.getInteger("HarvestLevel");
float blockHardness = block.getBlockHardness(world, x, y, z);
@@ -72,10 +72,12 @@ public abstract class HarvestTool extends ToolCore
localBlock.onBlockHarvested(world, x, y, z, localMeta, player);
if (blockHardness > 0f)
onBlockDestroyed(stack, world, localBlock, x, y, z, player);
world.func_147479_m(x, y, z);
}
else
{
WorldHelper.setBlockToAir(world, x, y, z);
world.func_147479_m(x, y, z);
}
}
}