mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
* Fix AutoFishing crash * Fix all warnings * Remove DotNetZip. * Fix the usage of HttpClient.
35 lines
1 KiB
C#
35 lines
1 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace MinecraftClient.Inventory.ItemPalettes
|
|
{
|
|
public abstract class ItemPalette
|
|
{
|
|
protected abstract Dictionary<int, ItemType> GetDict();
|
|
private readonly Dictionary<ItemType, int> DictReverse = new();
|
|
|
|
public ItemPalette()
|
|
{
|
|
// Index reverse mappings for use in ToId()
|
|
foreach (KeyValuePair<int, ItemType> entry in GetDict())
|
|
DictReverse.Add(entry.Value, entry.Key);
|
|
|
|
// Hardcoded placeholder types for internal and network use
|
|
DictReverse[ItemType.Unknown] = (int)ItemType.Unknown;
|
|
DictReverse[ItemType.Null] = (int)ItemType.Null;
|
|
}
|
|
|
|
public ItemType FromId(int id)
|
|
{
|
|
// Unknown item types may appear on Forge servers for custom items
|
|
if (!GetDict().ContainsKey(id))
|
|
return ItemType.Unknown;
|
|
|
|
return GetDict()[id];
|
|
}
|
|
|
|
public int ToId(ItemType itemType)
|
|
{
|
|
return DictReverse[itemType];
|
|
}
|
|
}
|
|
}
|