Kitchen Sink

Kitchen Sink

431k Downloads

[1.9] Killing entity with empty hand causes NPE

Ipsis opened this issue ยท 2 comments

commented

I had a crash bug raised against my mod Woot.

The KitchenSink "public void onDeath(LivingDeathEvent event)" function was crashing with an NPE, when my mod killed a mob that then raised that event.

I've added your event handler to my code to see what was going wrong and it is with the line
player.getHeldItem(EnumHand.MAIN_HAND).getItem()

Basically if the player is not holding any items when they kill an entity, then player.getHeldItem will return null, causing the NPE.

I reproduced it with a clean new world and just punching a pig to death :)

commented

Better late then never right? That is a pretty big bug, so even though I haven't been working on the mod I'll make sure to fix that and re-upload ASAP.

commented

Thank you for the amazing bug report, you could of just said the onDeath method and I could of found it, but hey you made my job that much easier.