Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
4829fbf6bd
* Handle custom registry elements properly * update error message Datapack made painting variant support is added in https://github.com/PaperMC/Paper/pull/11244 * change msg for art conversion --------- Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
46 Zeilen
2.6 KiB
Diff
46 Zeilen
2.6 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] 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 2de558dd205a1078fdcac1bce256d059b9bf5d5f..dc23b646e55bb66e0aa584d82b75b4b3d233276a 100644
|
|
--- a/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
|
+++ b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
|
@@ -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()) {
|
|
- this.selectedBannerPatternIndex.set(id);
|
|
- 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.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 (eventPattern.equals(holder)) {
|
|
+ selectablePatternIndex = i;
|
|
+ selectedPattern = holder;
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ if (selectedPattern == null) {
|
|
+ selectedPattern = eventPattern;
|
|
+ selectablePatternIndex = -1;
|
|
+ }
|
|
+
|
|
+ player.containerMenu.sendAllDataToRemote();
|
|
+ this.selectedBannerPatternIndex.set(selectablePatternIndex);
|
|
+ this.setupResultSlot(java.util.Objects.requireNonNull(selectedPattern, "selectedPattern was null, this is unexpected"));
|
|
+ // Paper end - Add PlayerLoomPatternSelectEvent
|
|
return true;
|
|
} else {
|
|
return false;
|