mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
33 lines
857 B
C#
33 lines
857 B
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
|
|||
|
|
namespace MinecraftClient.Inventory.ItemPalettes
|
|||
|
|
{
|
|||
|
|
public abstract class ItemPalette
|
|||
|
|
{
|
|||
|
|
protected abstract Dictionary<int, ItemType> GetDict();
|
|||
|
|
private readonly Dictionary<ItemType, int> DictReverse = new Dictionary<ItemType, int>();
|
|||
|
|
|
|||
|
|
public ItemPalette()
|
|||
|
|
{
|
|||
|
|
// Index reverse mappings for use in ToId()
|
|||
|
|
foreach (KeyValuePair<int, ItemType> entry in GetDict())
|
|||
|
|
DictReverse.Add(entry.Value, entry.Key);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public ItemType FromId(int id)
|
|||
|
|
{
|
|||
|
|
return GetDict()[id];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public int ToId(ItemType itemType)
|
|||
|
|
{
|
|||
|
|
if (itemType == ItemType.Null)
|
|||
|
|
return -1;
|
|||
|
|
return DictReverse[itemType];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|