mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-22 08:57:35 +01:00
fixup loom pattern select event patch
This commit is contained in:
parent
c5c2a5fe13
commit
bcdf1f96b8
@ -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<BannerPattern> eventPattern = org.bukkit.craftbukkit.block.banner.CraftPatternType.bukkitToMinecraftHolder(event.getPatternType());
|
||||
+ Holder<BannerPattern> selectedPattern = null;
|
||||
+ for (int i = 0; i < this.selectablePatterns.size(); i++) {
|
||||
+ final Holder<BannerPattern> 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;
|
||||
+ }
|
||||
+
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user