From a5848f637b5c05eb7116055ca59ebf940c60ef89 Mon Sep 17 00:00:00 2001 From: Dusan Milutinovic Date: Sun, 13 Feb 2022 15:00:32 +0100 Subject: [PATCH] Fixed a crash on older versions --- MinecraftClient/Protocol/Handlers/Protocol18.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 39805911..a4bb1b93 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -833,7 +833,12 @@ namespace MinecraftClient.Protocol.Handlers if (handler.GetInventoryEnabled()) { byte windowId = dataTypes.ReadNextByte(packetData); - int stateId = dataTypes.ReadNextVarInt(packetData); + + int stateId = -1; + + if(protocolversion >= MC1181Version) + stateId = dataTypes.ReadNextVarInt(packetData); + int elements = dataTypes.ReadNextVarInt(packetData); Dictionary inventorySlots = new Dictionary(); for (short slotId = 0; slotId < elements; slotId++) @@ -849,7 +854,12 @@ namespace MinecraftClient.Protocol.Handlers if (handler.GetInventoryEnabled()) { byte windowID = dataTypes.ReadNextByte(packetData); - int stateId = dataTypes.ReadNextVarInt(packetData); + + int stateId = -1; + + if(protocolversion >= MC1181Version) + stateId = dataTypes.ReadNextVarInt(packetData); + short slotID = dataTypes.ReadNextShort(packetData); Item item = dataTypes.ReadNextItemSlot(packetData, itemPalette); handler.OnSetSlot(windowID, slotID, item);