From cbe348555b91fadd11db0f0d60fc1e75eef1dd35 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Mon, 25 Jul 2022 17:08:59 +0800 Subject: [PATCH] Fix bug: drop single item cause exception --- MinecraftClient/McClient.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index 2f517021..3b9e8005 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -1537,12 +1537,17 @@ namespace MinecraftClient break; case WindowActionType.DropItem: if (inventory.Items.ContainsKey(slotId)) + { inventory.Items[slotId].Count--; + changedSlots.Add(new Tuple((short)slotId, inventory.Items[slotId])); + } if (inventory.Items[slotId].Count <= 0) + { inventory.Items.Remove(slotId); + changedSlots.Add(new Tuple((short)slotId, null)); + } - changedSlots.Add(new Tuple((short)slotId, inventory.Items[slotId])); break; case WindowActionType.DropItemStack: inventory.Items.Remove(slotId);