API reference Obsidian.API.Inventory
ItemStack class
public sealed class ItemStack : DataComponentsStorage, IEquatable<ItemStack>
In Obsidian.API.
Constructors
public ItemStack(Item holder, int count = 1, params IEnumerable<DataComponent> components);public ItemStack(ItemStack item, int count = 1);Properties
public int Count { get; set; }public ChatMessage CustomName { get; }public int Damage { get; }public IReadOnlyList<Enchantment> Enchantments { get; }public bool HasEnchantmentGlint { get; }public Item Holder { get; }public bool IsAir { get; }public ChatMessage ItemName { get; }public IReadOnlyList<ChatMessage> Lore { get; }public int MaxDamage { get; }public int MaxStackSize { get; }public bool Unbreakable { get; }Methods
public bool Equals(ItemStack other);public override bool Equals(object obj);Get<TValue>(PluginComponentType<TValue>)
public TValue Get<TValue>(PluginComponentType<TValue> type);The stack's value of a plugin's component type, or default when it has none.
public override int GetHashCode();Is(Item)
public bool Is(Item item);Whether the stack holds item.
Remove<TValue>(PluginComponentType<TValue>)
public bool Remove<TValue>(PluginComponentType<TValue> type);Removes the stack's value of a plugin's component type.
Returns
Whether the stack had one.
Set<TValue>(PluginComponentType<TValue>, TValue)
public void Set<TValue>(PluginComponentType<TValue> type, TValue value);Sets the stack's value of a plugin's component type, encoded with the type's codec. The stack keeps only the saved form, so it holds nothing of the plugin's.
public override string ToString();TransmuteCopy(Item)
public ItemStack TransmuteCopy(Item holder);Copies this stack, with its count and the components set on it, as a stack of holder (vanilla's transmuteCopy), e.g. to turn a book into an enchanted book.
TryGet<TValue>(PluginComponentType<TValue>, TValue)
public bool TryGet<TValue>(PluginComponentType<TValue> type, out TValue value);Reads the stack's value of a plugin's component type, decoded with the type's codec.
Returns
Whether the stack has a value of the type.
Remarks
A value saved before the type was first registered in this process is read too.
Operators
public static bool operator !=(ItemStack left, ItemStack right);public static ItemStack operator +(ItemStack item, int value);public static ItemStack operator +(ItemStack item, ItemStack value);public static ItemStack operator -(ItemStack item, int value);public static ItemStack operator /(ItemStack item, int value);public static bool operator ==(ItemStack left, ItemStack right);Fields
public static readonly ItemStack Air;