diff --git a/MinecraftClient/ChatBots/AutoDrop.cs b/MinecraftClient/ChatBots/AutoDrop.cs index ddf89d78..cf3142f0 100644 --- a/MinecraftClient/ChatBots/AutoDrop.cs +++ b/MinecraftClient/ChatBots/AutoDrop.cs @@ -200,6 +200,12 @@ namespace MinecraftClient.ChatBots { if (inventoryUpdated != -1) { + if (!GetInventories().ContainsKey(inventoryUpdated)) + { + // Inventory updated but no inventory ? + LogDebugToConsoleTranslated("bot.autoDrop.no_inventory", inventoryUpdated); + return; + } var inventory = GetInventories()[inventoryUpdated]; var items = inventory.Items.ToDictionary(entry => entry.Key, entry => entry.Value); if (dropMode == Mode.Include) diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index d4e9e20d..49e48619 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -1757,8 +1757,13 @@ namespace MinecraftClient public void OnInventoryClose(int inventoryID) { if (inventories.ContainsKey(inventoryID)) - inventories.Remove(inventoryID); - + { + if (inventoryID == 0) + inventories[0].Items.Clear(); // Don't delete player inventory + else + inventories.Remove(inventoryID); + } + if (inventoryID != 0) { Log.Info(Translations.Get("extra.inventory_close", inventoryID)); diff --git a/MinecraftClient/Resources/lang/en.ini b/MinecraftClient/Resources/lang/en.ini index d0485933..6a533201 100644 --- a/MinecraftClient/Resources/lang/en.ini +++ b/MinecraftClient/Resources/lang/en.ini @@ -388,6 +388,7 @@ bot.autoDrop.list=Total {0} in the list:\n {1} bot.autoDrop.switched=Switched to {0} mode. bot.autoDrop.unknown_mode=Unknwon mode. Available modes: Include, Exclude, Everything bot.autoDrop.no_mode=Cannot read drop mode from config. Using include mode. +bot.autoDrop.no_inventory=Cannot find inventory {0}! # AutoFish bot.autoFish.throw=Threw a fishing rod