mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 00:10:32 +01:00
89d51d5f29
Because this exploit has been widely known for years and has not been fixed by Mojang, we decided that it was worth allowing people to toggle it on/off due to how easy it is to make it configurable. It should be noted that this decision does not promise all future exploits will be configurable.
50 lines
2.8 KiB
Diff
50 lines
2.8 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 a98157f600837898dd8ef12671c4bb713e30f30c..e8c755dc71d9818f025eb25224122b19c5f9e15b 100644
|
|
--- a/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
|
+++ b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
|
@@ -173,8 +173,36 @@ 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.block.banner.PatternType.getByIdentifier(this.selectablePatterns.get(selectablePatternIndex).value().getHashname()));
|
|
+ if (!event.callEvent()) {
|
|
+ player.containerMenu.sendAllDataToRemote();
|
|
+ return false;
|
|
+ }
|
|
+ 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;
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ if (selectedPattern == null) {
|
|
+ for (BannerPattern pattern : BuiltInRegistries.BANNER_PATTERN) {
|
|
+ if (event.getPatternType().getIdentifier().equals(pattern.getHashname())) {
|
|
+ selectedPattern = BuiltInRegistries.BANNER_PATTERN.wrapAsHolder(pattern);
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ 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;
|