Archiviert
13
0

fixup loom pattern select event patch

Dieser Commit ist enthalten in:
Jake Potrebic 2024-04-25 22:44:49 -07:00
Ursprung c5c2a5fe13
Commit bcdf1f96b8
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: ECE0B3C133C016C5
2 geänderte Dateien mit 7 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -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 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 --- a/src/main/java/net/minecraft/world/inventory/LoomMenu.java
+++ b/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 @Override
public boolean clickMenuButton(net.minecraft.world.entity.player.Player player, int id) { public boolean clickMenuButton(net.minecraft.world.entity.player.Player player, int id) {
if (id >= 0 && id < this.selectablePatterns.size()) { if (id >= 0 && id < this.selectablePatterns.size()) {
@ -16,27 +16,23 @@ index 4bd720a97da27c4fd97788d4c504c0174f0f6c25..03b6622ec13338005005c9a11e0e6395
- this.setupResultSlot((Holder) this.selectablePatterns.get(id)); - this.setupResultSlot((Holder) this.selectablePatterns.get(id));
+ // Paper start - Add PlayerLoomPatternSelectEvent + // Paper start - Add PlayerLoomPatternSelectEvent
+ int selectablePatternIndex = id; + 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()) { + if (!event.callEvent()) {
+ player.containerMenu.sendAllDataToRemote(); + player.containerMenu.sendAllDataToRemote();
+ return false; + return false;
+ } + }
+ final Holder<BannerPattern> eventPattern = org.bukkit.craftbukkit.block.banner.CraftPatternType.bukkitToMinecraftHolder(event.getPatternType());
+ Holder<BannerPattern> selectedPattern = null; + Holder<BannerPattern> selectedPattern = null;
+ for (int i = 0; i < this.selectablePatterns.size(); i++) { + for (int i = 0; i < this.selectablePatterns.size(); i++) {
+ final Holder<BannerPattern> holder = this.selectablePatterns.get(i); + final Holder<BannerPattern> holder = this.selectablePatterns.get(i);
+ if (event.getPatternType().getIdentifier().equals(holder.value().getHashname())) { + if (eventPattern.equals(holder)) {
+ selectablePatternIndex = i; + selectablePatternIndex = i;
+ selectedPattern = holder; + selectedPattern = holder;
+ break; + break;
+ } + }
+ } + }
+ if (selectedPattern == null) { + if (selectedPattern == null) {
+ for (BannerPattern pattern : BuiltInRegistries.BANNER_PATTERN) { + selectedPattern = eventPattern;
+ if (event.getPatternType().getIdentifier().equals(pattern.getHashname())) {
+ selectedPattern = BuiltInRegistries.BANNER_PATTERN.wrapAsHolder(pattern);
+ break;
+ }
+ }
+ selectablePatternIndex = -1; + selectablePatternIndex = -1;
+ } + }
+ +

Datei anzeigen

@ -206,7 +206,7 @@ index be840717e180b6b5abd14db6cc9263349737f9a3..7de5e47f9a54263734eeef855a2dc07e
public void setChanged() { public void setChanged() {
super.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 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 --- a/src/main/java/net/minecraft/world/inventory/LoomMenu.java
+++ b/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 { @@ -73,7 +73,7 @@ public class LoomMenu extends AbstractContainerMenu {