From 9d8edad9fc107422f6ee35bcc799532147e486ec Mon Sep 17 00:00:00 2001 From: AJ Ferguson Date: Tue, 23 Apr 2024 06:13:19 -0400 Subject: [PATCH] Fix horse inventory --- .../inventory/JavaHorseScreenOpenTranslator.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/inventory/JavaHorseScreenOpenTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/inventory/JavaHorseScreenOpenTranslator.java index 58deaa0e9..33cfeaf31 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/inventory/JavaHorseScreenOpenTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/inventory/JavaHorseScreenOpenTranslator.java @@ -112,19 +112,23 @@ public class JavaHorseScreenOpenTranslator extends PacketTranslator slots = new ArrayList<>(); + // Since 1.20.5, the armor slot is not included in the container size, + // but everything is still indexed the same. + int slotCount = packet.getNumberOfSlots() + 1; + InventoryTranslator inventoryTranslator; if (entity instanceof LlamaEntity) { - inventoryTranslator = new LlamaInventoryTranslator(packet.getNumberOfSlots()); + inventoryTranslator = new LlamaInventoryTranslator(slotCount); slots.add(CARPET_SLOT); } else if (entity instanceof ChestedHorseEntity) { - inventoryTranslator = new DonkeyInventoryTranslator(packet.getNumberOfSlots()); + inventoryTranslator = new DonkeyInventoryTranslator(slotCount); slots.add(SADDLE_SLOT); } else if (entity instanceof CamelEntity) { // The camel has an invisible armor slot and needs special handling, same as the donkey - inventoryTranslator = new DonkeyInventoryTranslator(packet.getNumberOfSlots()); + inventoryTranslator = new DonkeyInventoryTranslator(slotCount); slots.add(SADDLE_SLOT); } else { - inventoryTranslator = new HorseInventoryTranslator(packet.getNumberOfSlots()); + inventoryTranslator = new HorseInventoryTranslator(slotCount); slots.add(SADDLE_SLOT); slots.add(ARMOR_SLOT); } @@ -136,6 +140,6 @@ public class JavaHorseScreenOpenTranslator extends PacketTranslator