Add PlayerInventorySlotChangeEvent

This commit is contained in:
Jakub Zacek
2022-04-24 22:56:59 +02:00
parent e56f757b1c
commit 4f1619700a
3 changed files with 139 additions and 92 deletions

View File

@@ -28,10 +28,11 @@
public abstract class AbstractContainerMenu {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -67,6 +81,32 @@
@@ -66,6 +80,32 @@
@Nullable
private ContainerSynchronizer synchronizer;
private boolean suppressRemoteUpdates;
+
+ // CraftBukkit start
+ public boolean checkReachable = true;
+ public abstract InventoryView getBukkitView();
@@ -57,10 +58,9 @@
+ this.title = title;
+ }
+ // CraftBukkit end
+
protected AbstractContainerMenu(@Nullable MenuType<?> type, int syncId) {
this.carried = ItemStack.EMPTY;
this.remoteSlots = NonNullList.create();
@@ -192,6 +232,15 @@
}
@@ -77,6 +77,15 @@
public void removeSlotListener(ContainerListener listener) {
this.containerListeners.remove(listener);
}
@@ -281,7 +330,7 @@
while (iterator.hasNext()) {
ContainerListener icrafting = (ContainerListener) iterator.next();
- icrafting.slotChanged(this, slot, itemstack2);
+ icrafting.slotChanged(this, slot, itemstack1, itemstack2); // Paper - Add PlayerInventorySlotChangeEvent
}
}
@@ -417,7 +466,7 @@
}
} else if (this.quickcraftStatus == 2) {

View File

@@ -0,0 +1,14 @@
--- a/net/minecraft/world/inventory/ContainerListener.java
+++ b/net/minecraft/world/inventory/ContainerListener.java
@@ -5,5 +5,11 @@
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);
}