Paper/patches/server/0567-Added-PlayerLoomPatternSelectEvent.patch
2022-06-02 21:26:56 -07:00

35 lines
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 fba8c59071847d9669943534ff8a0898b5787c28..1fefb682d34ab165444c45439dbc1ea28dc9079f 100644
--- a/src/main/java/net/minecraft/world/inventory/LoomMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
@@ -168,7 +168,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 {