mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-04-26 08:57:24 +00:00
Theres documentation at https://sylvessa.zip/fourkit/ now. And a bunch of other changes. Check the discord server for a more comprehensive list
103 lines
3.1 KiB
C#
103 lines
3.1 KiB
C#
namespace Minecraft.Server.FourKit.Inventory;
|
|
|
|
/// <summary>
|
|
/// Represents a stack of items.
|
|
/// </summary>
|
|
public class ItemStack
|
|
{
|
|
private Material _type;
|
|
private int _amount;
|
|
private short _durability;
|
|
|
|
/// <summary>
|
|
/// Creates a new ItemStack of the specified material with amount 1.
|
|
/// </summary>
|
|
public ItemStack(Material type) : this(type, 1) { }
|
|
|
|
/// <summary>
|
|
/// Creates a new ItemStack of the specified material and amount.
|
|
/// </summary>
|
|
public ItemStack(Material type, int amount) : this(type, amount, 0) { }
|
|
|
|
/// <summary>
|
|
/// Creates a new ItemStack of the specified material, amount and durability.
|
|
/// </summary>
|
|
public ItemStack(Material type, int amount, short durability)
|
|
{
|
|
_type = type;
|
|
_amount = amount;
|
|
_durability = durability;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a new ItemStack from a raw type ID with amount 1.
|
|
/// </summary>
|
|
public ItemStack(int typeId) : this(typeId, 1) { }
|
|
|
|
/// <summary>
|
|
/// Creates a new ItemStack from a raw type ID and amount.
|
|
/// </summary>
|
|
public ItemStack(int typeId, int amount) : this(typeId, amount, 0) { }
|
|
|
|
/// <summary>
|
|
/// Creates a new ItemStack from a raw type ID, amount and durability.
|
|
/// </summary>
|
|
public ItemStack(int typeId, int amount, short durability)
|
|
{
|
|
_type = Enum.IsDefined(typeof(Material), typeId) ? (Material)typeId : Material.AIR;
|
|
_amount = amount;
|
|
_durability = durability;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the type of this item.
|
|
/// </summary>
|
|
/// <returns>Type of the items in this stack.</returns>
|
|
public Material getType() => _type;
|
|
|
|
/// <summary>
|
|
/// Sets the type of this item.
|
|
/// </summary>
|
|
/// <param name="type">New type to set the items in this stack to.</param>
|
|
public void setType(Material type) => _type = type;
|
|
|
|
/// <summary>
|
|
/// Gets the type id for this item.
|
|
/// </summary>
|
|
/// <returns>Type Id of the items in this stack.</returns>
|
|
public int getTypeId() => (int)_type;
|
|
|
|
/// <summary>
|
|
/// Sets the type id for this item.
|
|
/// </summary>
|
|
/// <param name="type">New type id to set the items in this stack to.</param>
|
|
public void setTypeId(int type)
|
|
{
|
|
_type = Enum.IsDefined(typeof(Material), type) ? (Material)type : Material.AIR;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the amount of items in this stack.
|
|
/// </summary>
|
|
/// <returns>Amount of items in this stack.</returns>
|
|
public int getAmount() => _amount;
|
|
|
|
/// <summary>
|
|
/// Sets the amount of items in this stack.
|
|
/// </summary>
|
|
/// <param name="amount">New amount of items in this stack.</param>
|
|
public void setAmount(int amount) => _amount = amount;
|
|
|
|
/// <summary>
|
|
/// Gets the durability of this item.
|
|
/// </summary>
|
|
/// <returns>Durability of this item.</returns>
|
|
public short getDurability() => _durability;
|
|
|
|
/// <summary>
|
|
/// Sets the durability of this item.
|
|
/// </summary>
|
|
/// <param name="durability">Durability of this item.</param>
|
|
public void setDurability(short durability) => _durability = durability;
|
|
}
|