Paper/patches/server/0592-Added-PlayerLoomPatternSelectEvent.patch
Jason Penilla 9cfc0d5a60
Revert "Re-add Chunk Priority/Urgency System (#5829)"
This reverts commit 24b7da65ee.

Patch was updated incorrectly and needs a closer look.
2021-06-16 00:21:41 -07:00

35 Zeilen
1.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 25 Nov 2020 16:33:27 -0800
Subject: [PATCH] Added PlayerLoomPatternSelectEvent
diff --git a/src/main/java/net/minecraft/world/inventory/LoomMenu.java b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
index 7e8b6e0e69876cb7bfd444a8dd72edf8289e6dd1..51579f642859fc99c715dfcd286482995012d84a 100644
--- a/src/main/java/net/minecraft/world/inventory/LoomMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
@@ -166,7 +166,22 @@ public class LoomMenu extends AbstractContainerMenu {
@Override
public boolean clickMenuButton(net.minecraft.world.entity.player.Player player, int id) {
if (id > 0 && id <= BannerPattern.AVAILABLE_PATTERNS) {
- this.selectedBannerPatternIndex.set(id);
+ // Paper start
+ int enumBannerPatternTypeOrdinal = 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(BannerPattern.values()[id].getHashname()));
+ if (!event.callEvent()) {
+ ((Player) player.getBukkitEntity()).updateInventory();
+ return false;
+ }
+ for (BannerPattern nms : BannerPattern.values()) {
+ if (event.getPatternType().getIdentifier().equals(nms.getHashname())) {
+ enumBannerPatternTypeOrdinal = nms.ordinal();
+ break;
+ }
+ }
+ ((Player) player.getBukkitEntity()).updateInventory();
+ this.selectedBannerPatternIndex.set(enumBannerPatternTypeOrdinal);
+ // Paper end
this.setupResultSlot();
return true;
} else {