diff options
author | Jake Potrebic <[email protected]> | 2021-12-22 10:02:31 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2021-12-22 10:02:31 -0800 |
commit | 82eaf4ee15d77303cdd352cce9b33c2f3e5d14d7 (patch) | |
tree | 53e4a42978675fc17acc76b85dcb0c3569ab3e3b /patches/server/0590-Added-PlayerStonecutterRecipeSelectEvent.patch | |
parent | 6e5ceb34eb2ef4d6c0a35c46d0eded9099bb2fee (diff) | |
download | Paper-82eaf4ee15d77303cdd352cce9b33c2f3e5d14d7.tar.gz Paper-82eaf4ee15d77303cdd352cce9b33c2f3e5d14d7.zip |
Fix duplicated BlockPistonRetractEvent call (#7111)
Diffstat (limited to 'patches/server/0590-Added-PlayerStonecutterRecipeSelectEvent.patch')
-rw-r--r-- | patches/server/0590-Added-PlayerStonecutterRecipeSelectEvent.patch | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/patches/server/0590-Added-PlayerStonecutterRecipeSelectEvent.patch b/patches/server/0590-Added-PlayerStonecutterRecipeSelectEvent.patch new file mode 100644 index 0000000000..c8cefc8ca5 --- /dev/null +++ b/patches/server/0590-Added-PlayerStonecutterRecipeSelectEvent.patch @@ -0,0 +1,51 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic <[email protected]> +Date: Fri, 27 Nov 2020 17:14:27 -0800 +Subject: [PATCH] Added PlayerStonecutterRecipeSelectEvent + +Co-Authored-By: MiniDigger <[email protected]> + +diff --git a/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java b/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java +index 221b6ffb426edc034183dbaf37de29c694874c62..c597139b2b88edf629bc0021ebb65d8bea2e6a7d 100644 +--- a/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java ++++ b/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java +@@ -62,7 +62,7 @@ public class StonecutterMenu extends AbstractContainerMenu { + + public StonecutterMenu(int syncId, Inventory playerInventory, final ContainerLevelAccess context) { + super(MenuType.STONECUTTER, syncId); +- this.selectedRecipeIndex = DataSlot.standalone(); ++ this.selectedRecipeIndex = DataSlot.shared(new int[1], 0); // Paper - allow replication + this.recipes = Lists.newArrayList(); + this.input = ItemStack.EMPTY; + this.slotUpdateListener = () -> { +@@ -156,7 +156,29 @@ public class StonecutterMenu extends AbstractContainerMenu { + @Override + public boolean clickMenuButton(net.minecraft.world.entity.player.Player player, int id) { + if (this.isValidRecipeIndex(id)) { +- this.selectedRecipeIndex.set(id); ++ // Paper start ++ int recipeIndex = id; ++ this.selectedRecipeIndex.set(recipeIndex); ++ this.selectedRecipeIndex.checkAndClearUpdateFlag(); // mark as changed ++ if (this.isValidRecipeIndex(id)) { ++ io.papermc.paper.event.player.PlayerStonecutterRecipeSelectEvent event = new io.papermc.paper.event.player.PlayerStonecutterRecipeSelectEvent((Player) player.getBukkitEntity(), (org.bukkit.inventory.StonecutterInventory) getBukkitView().getTopInventory(), (org.bukkit.inventory.StonecuttingRecipe) this.getRecipes().get(id).toBukkitRecipe()); ++ if (!event.callEvent()) { ++ ((Player) player.getBukkitEntity()).updateInventory(); ++ return false; ++ } ++ int newRecipeIndex; ++ if (!this.getRecipes().get(recipeIndex).getId().equals(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getStonecuttingRecipe().getKey()))) { // If the recipe did NOT stay the same ++ for (newRecipeIndex = 0; newRecipeIndex < this.getRecipes().size(); newRecipeIndex++) { ++ if (this.getRecipes().get(newRecipeIndex).getId().equals(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getStonecuttingRecipe().getKey()))) { ++ recipeIndex = newRecipeIndex; ++ break; ++ } ++ } ++ } ++ } ++ ((Player) player.getBukkitEntity()).updateInventory(); ++ this.selectedRecipeIndex.set(recipeIndex); // set new index, so that listeners can read it ++ // Paper end + this.setupResultSlot(); + } + |