From 3362f69cab27e36c83779641ac7522f07a0e5746 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Thu, 1 Sep 2022 21:24:50 +0900 Subject: [PATCH] Fix potential NullPointerException --- .../TurnBasedMinecraft/common/OtherModHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/OtherModHandler.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/OtherModHandler.java index bfc8d05..0ffdf21 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/OtherModHandler.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/OtherModHandler.java @@ -83,7 +83,8 @@ public class OtherModHandler { final Class finalCustomNPCsIEntity = customNPCsIEntity; customNPCsEventBus.addListener(EventPriority.LOWEST, true, (event) -> { - if (finalCustomNPCsPlayerHurtEvent.isInstance(event)) { + if (finalCustomNPCsPlayerHurtEvent.isInstance(event) + && TurnBasedMinecraftMod.proxy.getAttackingEntity() != null) { Field damageSourceField; try { damageSourceField = finalCustomNPCsPlayerHurtEvent.getField("damageSource"); @@ -167,6 +168,7 @@ public class OtherModHandler { } } }); + TurnBasedMinecraftMod.logger.info("Enabled NpcAPI handling of Player damaged event"); } } }