From bcdf1f96b8d5ae0a513cf99f8cba7b9926afcb91 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Thu, 25 Apr 2024 22:44:49 -0700 Subject: [PATCH] fixup loom pattern select event patch --- .../0482-Add-PlayerLoomPatternSelectEvent.patch | 16 ++++++---------- ...missing-InventoryHolders-to-inventories.patch | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/patches/server/0482-Add-PlayerLoomPatternSelectEvent.patch b/patches/server/0482-Add-PlayerLoomPatternSelectEvent.patch index 8378c52f2e..4d74c20681 100644 --- a/patches/server/0482-Add-PlayerLoomPatternSelectEvent.patch +++ b/patches/server/0482-Add-PlayerLoomPatternSelectEvent.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add PlayerLoomPatternSelectEvent diff --git a/src/main/java/net/minecraft/world/inventory/LoomMenu.java b/src/main/java/net/minecraft/world/inventory/LoomMenu.java -index 4bd720a97da27c4fd97788d4c504c0174f0f6c25..03b6622ec13338005005c9a11e0e6395da1b15a7 100644 +index 4bd720a97da27c4fd97788d4c504c0174f0f6c25..72ad78659a373213ed1f37498754adaf18f1f68b 100644 --- a/src/main/java/net/minecraft/world/inventory/LoomMenu.java +++ b/src/main/java/net/minecraft/world/inventory/LoomMenu.java -@@ -174,8 +174,36 @@ public class LoomMenu extends AbstractContainerMenu { +@@ -174,8 +174,32 @@ public class LoomMenu extends AbstractContainerMenu { @Override public boolean clickMenuButton(net.minecraft.world.entity.player.Player player, int id) { if (id >= 0 && id < this.selectablePatterns.size()) { @@ -16,27 +16,23 @@ index 4bd720a97da27c4fd97788d4c504c0174f0f6c25..03b6622ec13338005005c9a11e0e6395 - this.setupResultSlot((Holder) this.selectablePatterns.get(id)); + // Paper start - Add PlayerLoomPatternSelectEvent + int selectablePatternIndex = id; -+ io.papermc.paper.event.player.PlayerLoomPatternSelectEvent event = new io.papermc.paper.event.player.PlayerLoomPatternSelectEvent((Player) player.getBukkitEntity(), ((CraftInventoryLoom) getBukkitView().getTopInventory()), org.bukkit.block.banner.PatternType.getByIdentifier(this.selectablePatterns.get(selectablePatternIndex).value().getHashname())); ++ io.papermc.paper.event.player.PlayerLoomPatternSelectEvent event = new io.papermc.paper.event.player.PlayerLoomPatternSelectEvent((Player) player.getBukkitEntity(), ((CraftInventoryLoom) getBukkitView().getTopInventory()), org.bukkit.craftbukkit.block.banner.CraftPatternType.minecraftHolderToBukkit((this.selectablePatterns.get(selectablePatternIndex)))); + if (!event.callEvent()) { + player.containerMenu.sendAllDataToRemote(); + return false; + } ++ final Holder eventPattern = org.bukkit.craftbukkit.block.banner.CraftPatternType.bukkitToMinecraftHolder(event.getPatternType()); + Holder selectedPattern = null; + for (int i = 0; i < this.selectablePatterns.size(); i++) { + final Holder holder = this.selectablePatterns.get(i); -+ if (event.getPatternType().getIdentifier().equals(holder.value().getHashname())) { ++ if (eventPattern.equals(holder)) { + selectablePatternIndex = i; + selectedPattern = holder; + break; + } + } + if (selectedPattern == null) { -+ for (BannerPattern pattern : BuiltInRegistries.BANNER_PATTERN) { -+ if (event.getPatternType().getIdentifier().equals(pattern.getHashname())) { -+ selectedPattern = BuiltInRegistries.BANNER_PATTERN.wrapAsHolder(pattern); -+ break; -+ } -+ } ++ selectedPattern = eventPattern; + selectablePatternIndex = -1; + } + diff --git a/patches/server/0914-Add-missing-InventoryHolders-to-inventories.patch b/patches/server/0914-Add-missing-InventoryHolders-to-inventories.patch index e8362fb24a..a2c5867c17 100644 --- a/patches/server/0914-Add-missing-InventoryHolders-to-inventories.patch +++ b/patches/server/0914-Add-missing-InventoryHolders-to-inventories.patch @@ -206,7 +206,7 @@ index be840717e180b6b5abd14db6cc9263349737f9a3..7de5e47f9a54263734eeef855a2dc07e public void setChanged() { super.setChanged(); diff --git a/src/main/java/net/minecraft/world/inventory/LoomMenu.java b/src/main/java/net/minecraft/world/inventory/LoomMenu.java -index 03b6622ec13338005005c9a11e0e6395da1b15a7..4a7df3429a2b43312eff9b36568761bea854df74 100644 +index 72ad78659a373213ed1f37498754adaf18f1f68b..4f3f6ea43030853bd9df067358a1f4d16c40e6d4 100644 --- a/src/main/java/net/minecraft/world/inventory/LoomMenu.java +++ b/src/main/java/net/minecraft/world/inventory/LoomMenu.java @@ -73,7 +73,7 @@ public class LoomMenu extends AbstractContainerMenu {