ItemView
Namespace Mc.Scripting.Inventories · Kind struct (readonly)
public readonly struct ItemViewA read-only view of an item stack inside an event: the item and the count. Blittable.
Remarks
Section titled “Remarks”Valid only during the dispatch it came from. ItemView.ToStack turns it into a full ItemStack (components, names, lore) that can be kept.
Properties
Section titled “Properties”| Member | Description |
|---|---|
int Count { get; } |
Stack size (0 when empty). |
string? CustomId { get; } |
The id of the custom item this is (ItemStack.CustomId), or null. |
bool HasComponents { get; } |
Whether the engine has the data components of this stack (false for plain stacks). |
bool IsEmpty { get; } |
Whether the stack is empty (no item, air or count 0). |
int ItemId { get; } |
Item registry id (0 for air / nothing). |
string Key { get; } |
The item key, e.g. |
public int Count { get; }Stack size (0 when empty).
CustomId
Section titled “CustomId”public string? CustomId { get; }The id of the custom item this is (ItemStack.CustomId), or null. Costs nothing for a stack without components.
HasComponents
Section titled “HasComponents”public bool HasComponents { get; }Whether the engine has the data components of this stack (false for plain stacks).
IsEmpty
Section titled “IsEmpty”public bool IsEmpty { get; }Whether the stack is empty (no item, air or count 0).
ItemId
Section titled “ItemId”public int ItemId { get; }Item registry id (0 for air / nothing).
public string Key { get; }The item key, e.g. “minecraft:diamond_sword” (empty for an empty stack).
Methods
Section titled “Methods”| Member | Description |
|---|---|
ItemStack ToStack() |
A copy of the stack with all its data components (names, lore, custom data …) that stays valid after the event. |
override string ToString() |
ToStack
Section titled “ToStack”public ItemStack ToStack()A copy of the stack with all its data components (names, lore, custom data …) that stays valid after the event. A view of a stack without components needs no call to the engine.
Returns ItemStack: The stack.
ToString
Section titled “ToString”public override string ToString()Returns string