Sync offhand slot in menus
Menus don't add slots for the offhand, so on sendAllDataToRemote calls the offhand slot isn't sent. This is not correct because you *can* put stuff into the offhand by pressing the offhand swap item
This commit is contained in:
@@ -61,7 +61,12 @@
|
||||
|
||||
protected AbstractContainerMenu(@Nullable MenuType<?> type, int syncId) {
|
||||
this.carried = ItemStack.EMPTY;
|
||||
@@ -192,6 +232,15 @@
|
||||
@@ -188,10 +228,20 @@
|
||||
|
||||
if (this.synchronizer != null) {
|
||||
this.synchronizer.sendInitialData(this, this.remoteSlots, this.remoteCarried, this.remoteDataSlots.toIntArray());
|
||||
+ this.synchronizer.sendOffHandSlotChange(); // Paper - Sync offhand slot in menus; update player's offhand since the offhand slot is not added to the slots for menus but can be changed by swapping from a menu slot
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -77,7 +82,7 @@
|
||||
public void removeSlotListener(ContainerListener listener) {
|
||||
this.containerListeners.remove(listener);
|
||||
}
|
||||
@@ -281,7 +330,7 @@
|
||||
@@ -281,7 +331,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
ContainerListener icrafting = (ContainerListener) iterator.next();
|
||||
|
||||
@@ -86,7 +91,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,7 +466,7 @@
|
||||
@@ -417,7 +467,7 @@
|
||||
}
|
||||
} else if (this.quickcraftStatus == 2) {
|
||||
if (!this.quickcraftSlots.isEmpty()) {
|
||||
@@ -95,7 +100,7 @@
|
||||
k = ((Slot) this.quickcraftSlots.iterator().next()).index;
|
||||
this.resetQuickCraft();
|
||||
this.doClick(k, this.quickcraftType, ClickType.PICKUP, player);
|
||||
@@ -433,6 +482,7 @@
|
||||
@@ -433,6 +483,7 @@
|
||||
l = this.getCarried().getCount();
|
||||
Iterator iterator = this.quickcraftSlots.iterator();
|
||||
|
||||
@@ -103,7 +108,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
Slot slot1 = (Slot) iterator.next();
|
||||
ItemStack itemstack2 = this.getCarried();
|
||||
@@ -443,12 +493,48 @@
|
||||
@@ -443,12 +494,48 @@
|
||||
int l1 = Math.min(AbstractContainerMenu.getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemstack1) + j1, k1);
|
||||
|
||||
l -= l1 - j1;
|
||||
@@ -155,7 +160,7 @@
|
||||
}
|
||||
|
||||
this.resetQuickCraft();
|
||||
@@ -466,8 +552,11 @@
|
||||
@@ -466,8 +553,11 @@
|
||||
if (slotIndex == -999) {
|
||||
if (!this.getCarried().isEmpty()) {
|
||||
if (clickaction == ClickAction.PRIMARY) {
|
||||
@@ -168,7 +173,7 @@
|
||||
} else {
|
||||
player.drop(this.getCarried().split(1), true);
|
||||
}
|
||||
@@ -530,6 +619,15 @@
|
||||
@@ -530,6 +620,15 @@
|
||||
}
|
||||
|
||||
slot.setChanged();
|
||||
@@ -184,7 +189,7 @@
|
||||
}
|
||||
} else {
|
||||
int j2;
|
||||
@@ -662,8 +760,9 @@
|
||||
@@ -662,8 +761,9 @@
|
||||
ItemStack itemstack = this.getCarried();
|
||||
|
||||
if (!itemstack.isEmpty()) {
|
||||
@@ -195,7 +200,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -893,6 +992,11 @@
|
||||
@@ -893,6 +993,11 @@
|
||||
}
|
||||
|
||||
public ItemStack getCarried() {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerSynchronizer.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerSynchronizer.java
|
||||
@@ -6,6 +6,7 @@
|
||||
public interface ContainerSynchronizer {
|
||||
void sendInitialData(AbstractContainerMenu handler, NonNullList<ItemStack> stacks, ItemStack cursorStack, int[] properties);
|
||||
|
||||
+ default void sendOffHandSlotChange() {} // Paper - Sync offhand slot in menus
|
||||
void sendSlotChange(AbstractContainerMenu handler, int slot, ItemStack stack);
|
||||
|
||||
void sendCarriedChange(AbstractContainerMenu handler, ItemStack stack);
|
||||
Reference in New Issue
Block a user