3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-19 14:30:17 +01:00

Fix horse inventory

Dieser Commit ist enthalten in:
AJ Ferguson 2024-04-23 06:13:19 -04:00 committet von Camotoy
Ursprung 3f499e3ec0
Commit 9d8edad9fc
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F

Datei anzeigen

@ -112,19 +112,23 @@ public class JavaHorseScreenOpenTranslator extends PacketTranslator<ClientboundH
NbtMapBuilder builder = NbtMap.builder(); NbtMapBuilder builder = NbtMap.builder();
List<NbtMap> slots = new ArrayList<>(); List<NbtMap> 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; InventoryTranslator inventoryTranslator;
if (entity instanceof LlamaEntity) { if (entity instanceof LlamaEntity) {
inventoryTranslator = new LlamaInventoryTranslator(packet.getNumberOfSlots()); inventoryTranslator = new LlamaInventoryTranslator(slotCount);
slots.add(CARPET_SLOT); slots.add(CARPET_SLOT);
} else if (entity instanceof ChestedHorseEntity) { } else if (entity instanceof ChestedHorseEntity) {
inventoryTranslator = new DonkeyInventoryTranslator(packet.getNumberOfSlots()); inventoryTranslator = new DonkeyInventoryTranslator(slotCount);
slots.add(SADDLE_SLOT); slots.add(SADDLE_SLOT);
} else if (entity instanceof CamelEntity) { } else if (entity instanceof CamelEntity) {
// The camel has an invisible armor slot and needs special handling, same as the donkey // 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); slots.add(SADDLE_SLOT);
} else { } else {
inventoryTranslator = new HorseInventoryTranslator(packet.getNumberOfSlots()); inventoryTranslator = new HorseInventoryTranslator(slotCount);
slots.add(SADDLE_SLOT); slots.add(SADDLE_SLOT);
slots.add(ARMOR_SLOT); slots.add(ARMOR_SLOT);
} }
@ -136,6 +140,6 @@ public class JavaHorseScreenOpenTranslator extends PacketTranslator<ClientboundH
session.sendUpstreamPacket(updateEquipPacket); session.sendUpstreamPacket(updateEquipPacket);
session.setInventoryTranslator(inventoryTranslator); session.setInventoryTranslator(inventoryTranslator);
InventoryUtils.openInventory(session, new Container(entity.getNametag(), packet.getContainerId(), packet.getNumberOfSlots(), null, session.getPlayerInventory())); InventoryUtils.openInventory(session, new Container(entity.getNametag(), packet.getContainerId(), slotCount, null, session.getPlayerInventory()));
} }
} }