From 883d523cc7ffea7fad0f76cc73bcf1d7be372a5d Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sat, 23 Apr 2022 18:48:00 -0700 Subject: [PATCH] Fix opening inv in PlayerRecipeBookClickEvent handler (#7552) --- .../Add-and-implement-PlayerRecipeBookClickEvent.patch | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/patches/server/Add-and-implement-PlayerRecipeBookClickEvent.patch b/patches/server/Add-and-implement-PlayerRecipeBookClickEvent.patch index 351e9bb0c8..5d623a45ea 100644 --- a/patches/server/Add-and-implement-PlayerRecipeBookClickEvent.patch +++ b/patches/server/Add-and-implement-PlayerRecipeBookClickEvent.patch @@ -14,13 +14,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 } }