using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MinecraftClient.Inventory { /// /// Represents an item inside a Container /// public class Item { /// /// Item Type /// public ItemType Type; /// /// Item Count /// public int Count; /// /// Item Metadata /// public Dictionary NBT; /// /// Create an item with Type ID, Count and Metadata /// /// Item Type ID /// Item Count /// Item Metadata public Item(int id, int count, Dictionary nbt) { this.Type = (ItemType)id; this.Count = count; this.NBT = nbt; } /// /// Check if the item slot is empty /// /// TRUE if the item is empty public bool IsEmpty { get { return Type == ItemType.Air || Count == 0; } } /// /// Retrieve item display name from NBT properties. NULL if no display name is defined. /// public string DisplayName { get { if (NBT != null && NBT.ContainsKey("display")) { var displayProperties = NBT["display"] as Dictionary; if (displayProperties != null && displayProperties.ContainsKey("Name")) { string displayName = displayProperties["Name"] as string; if (!String.IsNullOrEmpty(displayName)) return MinecraftClient.Protocol.ChatParser.ParseText(displayProperties["Name"].ToString()); } } return null; } } } }