mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-04 16:34:44 +01:00
6e71f41536
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing CraftBukkit Changes: 65247583f SPIGOT-7857: Improve ItemMeta block data deserialization 05d80500d SPIGOT-7857: Fix spurious internal NBT tag when deserializing BlockStateMeta cebb58e9a SPIGOT-7804: Fix written book serialization efcdd5d38 SPIGOT-7794: Cancelling InventoryItemMoveEvent destroys items b568ba572 SPIGOT-7789: Fix NPE in CraftMetaFirework applyToItem f057cf449 Remove outdated build delay Spigot Changes: f6a48054 SPIGOT-7835: Fix issue with custom hopper settings bb63b137 Rebuild patches e1142b4d Rebuild patches
66 lines
3.8 KiB
Diff
66 lines
3.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jakub Zacek <dawon@dawon.eu>
|
|
Date: Sun, 24 Apr 2022 22:56:59 +0200
|
|
Subject: [PATCH] Add PlayerInventorySlotChangeEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
index 5647a2c7788b09eb8b14286b0ded0a64c244e25b..cd07b3e1bc12eb8474a74fb08ee6521b5674b105 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -347,6 +347,25 @@ public class ServerPlayer extends Player {
|
|
|
|
}
|
|
}
|
|
+ // Paper start - Add PlayerInventorySlotChangeEvent
|
|
+ @Override
|
|
+ public void slotChanged(AbstractContainerMenu handler, int slotId, ItemStack oldStack, ItemStack stack) {
|
|
+ Slot slot = handler.getSlot(slotId);
|
|
+ if (!(slot instanceof ResultSlot)) {
|
|
+ if (slot.container == ServerPlayer.this.getInventory()) {
|
|
+ if (io.papermc.paper.event.player.PlayerInventorySlotChangeEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
|
+ CriteriaTriggers.INVENTORY_CHANGED.trigger(ServerPlayer.this, ServerPlayer.this.getInventory(), stack);
|
|
+ return;
|
|
+ }
|
|
+ io.papermc.paper.event.player.PlayerInventorySlotChangeEvent event = new io.papermc.paper.event.player.PlayerInventorySlotChangeEvent(ServerPlayer.this.getBukkitEntity(), slotId, CraftItemStack.asBukkitCopy(oldStack), CraftItemStack.asBukkitCopy(stack));
|
|
+ event.callEvent();
|
|
+ if (event.shouldTriggerAdvancements()) {
|
|
+ CriteriaTriggers.INVENTORY_CHANGED.trigger(ServerPlayer.this, ServerPlayer.this.getInventory(), stack);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Paper end - Add PlayerInventorySlotChangeEvent
|
|
|
|
@Override
|
|
public void dataChanged(AbstractContainerMenu handler, int property, int value) {}
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
|
|
index 00031a013d8e1e9f40bc1ef9491da6df3b061d5f..ea84d4549815ddfd2829cb2fd3885ddd1114bfa8 100644
|
|
--- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
|
|
+++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
|
|
@@ -302,7 +302,7 @@ public abstract class AbstractContainerMenu {
|
|
while (iterator.hasNext()) {
|
|
ContainerListener icrafting = (ContainerListener) iterator.next();
|
|
|
|
- icrafting.slotChanged(this, slot, itemstack2);
|
|
+ icrafting.slotChanged(this, slot, itemstack1, itemstack2); // Paper - Add PlayerInventorySlotChangeEvent
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/ContainerListener.java b/src/main/java/net/minecraft/world/inventory/ContainerListener.java
|
|
index 0e19cc55646625bf32a354d3df2dc2d6bcff96f4..eba024c9aadef8902aacccea1584ffbee6c04e44 100644
|
|
--- a/src/main/java/net/minecraft/world/inventory/ContainerListener.java
|
|
+++ b/src/main/java/net/minecraft/world/inventory/ContainerListener.java
|
|
@@ -5,5 +5,11 @@ import net.minecraft.world.item.ItemStack;
|
|
public interface ContainerListener {
|
|
void slotChanged(AbstractContainerMenu handler, int slotId, ItemStack stack);
|
|
|
|
+ // Paper start - Add PlayerInventorySlotChangeEvent
|
|
+ default void slotChanged(AbstractContainerMenu handler, int slotId, ItemStack oldStack, ItemStack stack) {
|
|
+ slotChanged(handler, slotId, stack);
|
|
+ }
|
|
+ // Paper end - Add PlayerInventorySlotChangeEvent
|
|
+
|
|
void dataChanged(AbstractContainerMenu handler, int property, int value);
|
|
}
|