namespace Minecraft.Server.FourKit.Inventory; /// /// Represents a stack of items. /// public class ItemStack { private Material _type; private int _amount; private short _durability; /// /// Creates a new ItemStack of the specified material with amount 1. /// public ItemStack(Material type) : this(type, 1) { } /// /// Creates a new ItemStack of the specified material and amount. /// public ItemStack(Material type, int amount) : this(type, amount, 0) { } /// /// Creates a new ItemStack of the specified material, amount and durability. /// public ItemStack(Material type, int amount, short durability) { _type = type; _amount = amount; _durability = durability; } /// /// Creates a new ItemStack from a raw type ID with amount 1. /// public ItemStack(int typeId) : this(typeId, 1) { } /// /// Creates a new ItemStack from a raw type ID and amount. /// public ItemStack(int typeId, int amount) : this(typeId, amount, 0) { } /// /// Creates a new ItemStack from a raw type ID, amount and durability. /// public ItemStack(int typeId, int amount, short durability) { _type = Enum.IsDefined(typeof(Material), typeId) ? (Material)typeId : Material.AIR; _amount = amount; _durability = durability; } /// /// Gets the type of this item. /// /// Type of the items in this stack. public Material getType() => _type; /// /// Sets the type of this item. /// /// New type to set the items in this stack to. public void setType(Material type) => _type = type; /// /// Gets the type id for this item. /// /// Type Id of the items in this stack. public int getTypeId() => (int)_type; /// /// Sets the type id for this item. /// /// New type id to set the items in this stack to. public void setTypeId(int type) { _type = Enum.IsDefined(typeof(Material), type) ? (Material)type : Material.AIR; } /// /// Gets the amount of items in this stack. /// /// Amount of items in this stack. public int getAmount() => _amount; /// /// Sets the amount of items in this stack. /// /// New amount of items in this stack. public void setAmount(int amount) => _amount = amount; /// /// Gets the durability of this item. /// /// Durability of this item. public short getDurability() => _durability; /// /// Sets the durability of this item. /// /// Durability of this item. public void setDurability(short durability) => _durability = durability; }