Skip to content

ItemView

Namespace Mc.Scripting.Inventories · Kind struct (readonly)

public readonly struct ItemView

A read-only view of an item stack inside an event: the item and the count. Blittable.

Valid only during the dispatch it came from. ItemView.ToStack turns it into a full ItemStack (components, names, lore) that can be kept.

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).

public string? CustomId { get; }

The id of the custom item this is (ItemStack.CustomId), or null. Costs nothing for a stack without components.

public bool HasComponents { get; }

Whether the engine has the data components of this stack (false for plain stacks).

public bool IsEmpty { get; }

Whether the stack is empty (no item, air or count 0).

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).

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()
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.

public override string ToString()

Returns string

ItemStack