2021-06-14 21:17:47 +02:00
|
|
|
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
|
2024-01-19 22:13:42 +01:00
|
|
|
Subject: [PATCH] Add PlayerLoomPatternSelectEvent
|
2021-06-14 21:17:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/LoomMenu.java b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
|
|
|
@@ -0,0 +0,0 @@ public class LoomMenu extends AbstractContainerMenu {
|
|
|
|
@Override
|
|
|
|
public boolean clickMenuButton(net.minecraft.world.entity.player.Player player, int id) {
|
2022-06-08 09:30:41 +02:00
|
|
|
if (id >= 0 && id < this.selectablePatterns.size()) {
|
2021-06-14 21:17:47 +02:00
|
|
|
- this.selectedBannerPatternIndex.set(id);
|
2022-06-08 09:30:41 +02:00
|
|
|
- this.setupResultSlot((Holder) this.selectablePatterns.get(id));
|
2024-01-19 22:13:42 +01:00
|
|
|
+ // Paper start - Add PlayerLoomPatternSelectEvent
|
2022-06-08 09:30:41 +02:00
|
|
|
+ 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()));
|
2021-06-14 21:17:47 +02:00
|
|
|
+ if (!event.callEvent()) {
|
2024-02-01 10:15:57 +01:00
|
|
|
+ player.containerMenu.sendAllDataToRemote();
|
2021-06-14 21:17:47 +02:00
|
|
|
+ return false;
|
|
|
|
+ }
|
2022-06-08 09:30:41 +02:00
|
|
|
+ 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())) {
|
|
|
|
+ selectablePatternIndex = i;
|
|
|
|
+ selectedPattern = holder;
|
2021-06-14 21:17:47 +02:00
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
2022-06-08 09:30:41 +02:00
|
|
|
+ if (selectedPattern == null) {
|
2022-12-08 05:24:59 +01:00
|
|
|
+ for (BannerPattern pattern : BuiltInRegistries.BANNER_PATTERN) {
|
2022-06-08 09:30:41 +02:00
|
|
|
+ if (event.getPatternType().getIdentifier().equals(pattern.getHashname())) {
|
2024-02-01 10:15:57 +01:00
|
|
|
+ selectedPattern = BuiltInRegistries.BANNER_PATTERN.wrapAsHolder(pattern);
|
2022-06-08 09:30:41 +02:00
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ selectablePatternIndex = -1;
|
|
|
|
+ }
|
2024-02-01 10:15:57 +01:00
|
|
|
+
|
|
|
|
+ player.containerMenu.sendAllDataToRemote();
|
2022-06-08 09:30:41 +02:00
|
|
|
+ this.selectedBannerPatternIndex.set(selectablePatternIndex);
|
|
|
|
+ this.setupResultSlot(java.util.Objects.requireNonNull(selectedPattern, "selectedPattern was null, this is unexpected"));
|
2024-01-19 22:13:42 +01:00
|
|
|
+ // Paper end - Add PlayerLoomPatternSelectEvent
|
2021-06-14 21:17:47 +02:00
|
|
|
return true;
|
|
|
|
} else {
|
2022-06-08 09:30:41 +02:00
|
|
|
return false;
|