From 864f616da6e37ece5283ee108b795889835e3271 Mon Sep 17 00:00:00 2001 From: Parker Hawke Date: Sun, 12 Nov 2023 19:09:58 -0500 Subject: [PATCH] SPIGOT-7518: Fix NullPointerException when calling Block#applyBoneMeal() --- .../minecraft/world/item/ItemBoneMeal.patch | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/nms-patches/net/minecraft/world/item/ItemBoneMeal.patch b/nms-patches/net/minecraft/world/item/ItemBoneMeal.patch index 31e2bb214..0e32a858e 100644 --- a/nms-patches/net/minecraft/world/item/ItemBoneMeal.patch +++ b/nms-patches/net/minecraft/world/item/ItemBoneMeal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemBoneMeal.java +++ b/net/minecraft/world/item/ItemBoneMeal.java -@@ -34,6 +34,12 @@ +@@ -34,13 +34,19 @@ @Override public EnumInteractionResult useOn(ItemActionContext itemactioncontext) { @@ -13,3 +13,20 @@ World world = itemactioncontext.getLevel(); BlockPosition blockposition = itemactioncontext.getClickedPos(); BlockPosition blockposition1 = blockposition.relative(itemactioncontext.getClickedFace()); + + if (growCrop(itemactioncontext.getItemInHand(), world, blockposition)) { + if (!world.isClientSide) { +- itemactioncontext.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); ++ if (itemactioncontext.getPlayer() != null) itemactioncontext.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); // CraftBukkit - SPIGOT-7518 + world.levelEvent(1505, blockposition, 0); + } + +@@ -51,7 +57,7 @@ + + if (flag && growWaterPlant(itemactioncontext.getItemInHand(), world, blockposition1, itemactioncontext.getClickedFace())) { + if (!world.isClientSide) { +- itemactioncontext.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); ++ if (itemactioncontext.getPlayer() != null) itemactioncontext.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); // CraftBukkit - SPIGOT-7518 + world.levelEvent(1505, blockposition1, 0); + } +