[1.9] Killing entity with empty hand causes NPE
Ipsis opened this issue ยท 2 comments
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 :)
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.