mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
63 lines
3.3 KiB
Diff
63 lines
3.3 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 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 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryLoom;
|
|
import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
|
import org.bukkit.entity.Player;
|
|
// CraftBukkit end
|
|
+import io.papermc.paper.event.player.PlayerLoomPatternSelectEvent; // Paper
|
|
|
|
public class LoomMenu extends AbstractContainerMenu {
|
|
|
|
@@ -0,0 +0,0 @@ public class LoomMenu extends AbstractContainerMenu {
|
|
}
|
|
// CraftBukkit end
|
|
private final ContainerLevelAccess access;
|
|
- private final DataSlot selectedBannerPatternIndex;
|
|
+ private final DataSlot selectedBannerPatternIndex; public final DataSlot getSelectedBannerPattern() { return this.selectedBannerPatternIndex; }; // Paper - OBFHELPER
|
|
private Runnable slotUpdateListener;
|
|
private final Slot bannerSlot;
|
|
private final Slot dyeSlot;
|
|
@@ -0,0 +0,0 @@ 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;
|
|
+ PlayerLoomPatternSelectEvent event = new PlayerLoomPatternSelectEvent((Player) player.getBukkitEntity(), ((CraftInventoryLoom) getBukkitView().getTopInventory()), org.bukkit.block.banner.PatternType.getByIdentifier(BannerPattern.values()[id].getIdentifier()));
|
|
+ if (!event.callEvent()) {
|
|
+ ((Player) player.getBukkitEntity()).updateInventory();
|
|
+ return false;
|
|
+ }
|
|
+ for (BannerPattern nms : BannerPattern.values()) {
|
|
+ if (event.getPatternType().getIdentifier().equals(nms.getIdentifier())) {
|
|
+ enumBannerPatternTypeOrdinal = nms.ordinal();
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ ((Player) player.getBukkitEntity()).updateInventory();
|
|
+ this.getSelectedBannerPattern().set(enumBannerPatternTypeOrdinal);
|
|
+ // Paper end
|
|
this.setupResultSlot();
|
|
return true;
|
|
} else {
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BannerPattern.java b/src/main/java/net/minecraft/world/level/block/entity/BannerPattern.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/BannerPattern.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/BannerPattern.java
|
|
@@ -0,0 +0,0 @@ public enum BannerPattern {
|
|
this.hasPatternItem = flag;
|
|
}
|
|
|
|
+ public String getIdentifier() { return this.getHashname(); } // Paper - OBFHELPER
|
|
public String getHashname() {
|
|
return this.hashname;
|
|
}
|