Skip to content

Commit

Permalink
make sure that empty hand's don't cause NPE's in the even handler
Browse files Browse the repository at this point in the history
  • Loading branch information
progwml6 committed Mar 2, 2014
1 parent 9b4b59a commit 5b81260
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/main/java/tconstruct/util/TEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,14 @@ public static ItemStack craftFletching (ItemStack stack)

public static boolean matchesLeaves (ItemStack stack)
{
Block block = BlockUtils.getBlockFromItem(stack.getItem());
if (block != null)
if (stack != null)
{
if (block.isLeaves(null, 0, 0, 0))
return true;
Block block = BlockUtils.getBlockFromItem(stack.getItem());
if (block != null)
{
if (block.isLeaves(null, 0, 0, 0))
return true;
}
}
return false;
}
Expand Down Expand Up @@ -367,15 +370,15 @@ public void onLivingDrop (LivingDropsEvent event)
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
{
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
if (stack.getItem() == TRepo.cleaver)
if (stack != null && stack.hasTagCompound() && stack.getItem() == TRepo.cleaver)
beheading += 2;
if (beheading > 0 && random.nextInt(100) < beheading * 10)
{
addDrops(event, new ItemStack(Items.skull, 1, 2));
}
}

if (stack.getItem() == TRepo.cleaver && random.nextInt(100) < 10) //Swap out for real beheading
if (stack != null && stack.hasTagCompound() && stack.getItem() == TRepo.cleaver && random.nextInt(100) < 10) //Swap out for real beheading
{
addDrops(event, new ItemStack(Items.skull, 1, 2));
}
Expand Down

0 comments on commit 5b81260

Please sign in to comment.