diff --git a/MinecraftClient/Inventory/ItemPalettes/ItemPalette.cs b/MinecraftClient/Inventory/ItemPalettes/ItemPalette.cs index 76edb098..54afe69b 100644 --- a/MinecraftClient/Inventory/ItemPalettes/ItemPalette.cs +++ b/MinecraftClient/Inventory/ItemPalettes/ItemPalette.cs @@ -15,17 +15,22 @@ namespace MinecraftClient.Inventory.ItemPalettes // Index reverse mappings for use in ToId() foreach (KeyValuePair entry in GetDict()) DictReverse.Add(entry.Value, entry.Key); + + DictReverse[ItemType.Unknown] = -2; + DictReverse[ItemType.Null] = -1; } public ItemType FromId(int id) { + // Unknown item types may appear of Forge servers for custom items + if (!GetDict().ContainsKey(id)) + return ItemType.Unknown; + return GetDict()[id]; } public int ToId(ItemType itemType) { - if (itemType == ItemType.Null) - return -1; return DictReverse[itemType]; } } diff --git a/MinecraftClient/Inventory/ItemType.cs b/MinecraftClient/Inventory/ItemType.cs index 10b6ac8b..ed37efff 100644 --- a/MinecraftClient/Inventory/ItemType.cs +++ b/MinecraftClient/Inventory/ItemType.cs @@ -12,7 +12,8 @@ namespace MinecraftClient.Inventory /// public enum ItemType { - Null = -1, // Unspecified item type + Unknown = -2, // Unsupported item type (Forge mod custom item...) + Null = -1, // Unspecified item type (Used in the network protocol) AcaciaBoat, AcaciaButton,