Fix Player#didCloseInventory

This commit is contained in:
Felix Cravic 2020-07-01 17:25:25 +02:00
parent eb9aa8b6b6
commit ce06919da1
4 changed files with 6 additions and 5 deletions

View File

@ -227,7 +227,6 @@ public class Inventory implements InventoryModifier, InventoryClickHandler, View
private WindowItemsPacket createWindowItemsPacket() {
WindowItemsPacket windowItemsPacket = new WindowItemsPacket();
windowItemsPacket.windowId = getWindowId();
windowItemsPacket.count = (short) itemStacks.length;
windowItemsPacket.items = itemStacks;
return windowItemsPacket;
}

View File

@ -334,7 +334,6 @@ public class PlayerInventory implements InventoryModifier, InventoryClickHandler
WindowItemsPacket windowItemsPacket = new WindowItemsPacket();
windowItemsPacket.windowId = 0;
windowItemsPacket.count = INVENTORY_SIZE;
windowItemsPacket.items = convertedSlots;
return windowItemsPacket;
}

View File

@ -502,6 +502,10 @@ public class InventoryClickProcessor {
slot = slot - inventorySlot + PlayerInventoryUtils.OFFSET;
}
// Reset the didCloseInventory field
// Wait for inventory conditions + events to possibly close the inventory
player.UNSAFE_changeDidCloseInventory(false);
List<InventoryCondition> inventoryConditions = isPlayerInventory ?
player.getInventory().getInventoryConditions() : inventory.getInventoryConditions();
if (!inventoryConditions.isEmpty()) {

View File

@ -7,13 +7,12 @@ import net.minestom.server.network.packet.server.ServerPacketIdentifier;
public class WindowItemsPacket implements ServerPacket {
public int windowId;
public short count;
public byte windowId;
public ItemStack[] items;
@Override
public void write(PacketWriter writer) {
writer.writeVarInt(windowId);
writer.writeByte(windowId);
if (items == null) {
writer.writeShort((short) 0);