diff options
author | Jake Potrebic <[email protected]> | 2022-04-23 18:48:00 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2022-04-23 18:48:00 -0700 |
commit | 0bf7c95c8d8144c4f9ee1ec7b70f00ea7b9c5bf9 (patch) | |
tree | f4de6f688f79221d816163f46ac7b2066744f2a1 | |
parent | 4dc78ae8b98fb90ba5c72fd0f1346b62221ce7c3 (diff) | |
download | Paper-0bf7c95c8d8144c4f9ee1ec7b70f00ea7b9c5bf9.tar.gz Paper-0bf7c95c8d8144c4f9ee1ec7b70f00ea7b9c5bf9.zip |
Fix opening inv in PlayerRecipeBookClickEvent handler (#7552)
-rw-r--r-- | patches/server/0441-Add-and-implement-PlayerRecipeBookClickEvent.patch | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/patches/server/0441-Add-and-implement-PlayerRecipeBookClickEvent.patch b/patches/server/0441-Add-and-implement-PlayerRecipeBookClickEvent.patch index b3fd392b2b..51374e4c71 100644 --- a/patches/server/0441-Add-and-implement-PlayerRecipeBookClickEvent.patch +++ b/patches/server/0441-Add-and-implement-PlayerRecipeBookClickEvent.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add and implement PlayerRecipeBookClickEvent diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index a0597bf8d948f20becd7ccb748a78f8a14a54cf6..7c97e6eda860b0145d8d5700fcecdcea5e258a03 100644 +index a0597bf8d948f20becd7ccb748a78f8a14a54cf6..d55afdb09af8bc07361c06453a028da36ef934eb 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -2805,9 +2805,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser @@ -14,13 +14,14 @@ index a0597bf8d948f20becd7ccb748a78f8a14a54cf6..7c97e6eda860b0145d8d5700fcecdcea if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.getContainerId() && this.player.containerMenu instanceof RecipeBookMenu) { - this.server.getRecipeManager().byKey(packet.getRecipe()).ifPresent((irecipe) -> { - ((RecipeBookMenu) this.player.containerMenu).handlePlacement(packet.isShiftDown(), irecipe, this.player); +- }); + // Paper start - fire event for clicking recipes in the recipe book + com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent event = new com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent( + player.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(packet.getRecipe()), packet.isShiftDown()); -+ if (event.callEvent()) { ++ if (event.callEvent() && this.player.containerMenu instanceof RecipeBookMenu<?> recipeBookMenu) { // check if inventory changed during event handling + this.server.getRecipeManager().byKey(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getRecipe())).ifPresent((irecipe) -> { -+ ((RecipeBookMenu) this.player.containerMenu).handlePlacement(event.isMakeAll(), irecipe, this.player); - }); ++ recipeBookMenu.handlePlacement(event.isMakeAll(), irecipe, this.player); ++ }); + } // Paper end } } |