From 4b08912407131c08fc1dad592a753f3783462fa4 Mon Sep 17 00:00:00 2001 From: ReinforceZwei <39955851+ReinforceZwei@users.noreply.github.com> Date: Tue, 24 Mar 2020 16:13:05 +0800 Subject: [PATCH] Made Open Window to only parse packet before MC1.14 --- MinecraftClient/Protocol/Handlers/Protocol18.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index d7ae3b49..1d75880f 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -490,14 +490,17 @@ namespace MinecraftClient.Protocol.Handlers case PacketIncomingType.OpenWindow: if (handler.GetInventoryEnabled()) { - byte windowID = dataTypes.ReadNextByte(packetData); - string type = dataTypes.ReadNextString(packetData).Replace("minecraft:", "").ToUpper(); - InventoryType inventoryType = (InventoryType)Enum.Parse(typeof(InventoryType), type); - string title = dataTypes.ReadNextString(packetData); - byte slots = dataTypes.ReadNextByte(packetData); - Inventory inventory = new Inventory(windowID, inventoryType, title, slots); + if (protocolversion < MC114Version) // packet changed at 1.14 + { + byte windowID = dataTypes.ReadNextByte(packetData); + string type = dataTypes.ReadNextString(packetData).Replace("minecraft:", "").ToUpper(); + InventoryType inventoryType = (InventoryType)Enum.Parse(typeof(InventoryType), type); + string title = dataTypes.ReadNextString(packetData); + byte slots = dataTypes.ReadNextByte(packetData); + Inventory inventory = new Inventory(windowID, inventoryType, title, slots); - handler.OnInventoryOpen(inventory); + handler.OnInventoryOpen(inventory); + } } break; case PacketIncomingType.CloseWindow: