mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-05 10:20:53 +01:00
526795bacd
* Update patches to handle vineflower decompiler * update patches again to handle inlined simple lambdas * update vf again and re-apply/rebuild patches * update patches after removal of verify-merges flag * fix compile issue * remove maven local * fix some issues * address more issues * fix collision patch * use paperweight release * more fixes * update fineflower and fix patches again * add missing comment descriptor --------- Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
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 d831fb1f66dc38b6c9d3592944f94cc5eeaac864..2a1722db668b141705ce47389cd24d0a247e373d 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -330,6 +330,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 94fe6bd403222049e4e7a407bb6ca99bcaab6acb..399b2f4ddb7e9ef26fbc5e83f3b77c46d3868814 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);
|
|
}
|