Skip to content

EngineInventory

Namespace Mc.Scripting.Inventories · Kind class (abstract)

public abstract class EngineInventory : IInventory

Shared implementation of the inventories the engine owns: one native call per operation, the inventory is addressed by (kind, world, reference) every time, so a handle never keeps anything alive and a block that was destroyed meanwhile simply reads as an empty inventory.

Member Description
IEnumerable<ItemStack> Contents { get; }
bool Exists { get; } Whether the inventory still exists (a destroyed block entity or a closed player has none).
virtual int Size { get; }
public IEnumerable<ItemStack> Contents { get; }
public bool Exists { get; }

Whether the inventory still exists (a destroyed block entity or a closed player has none).

public virtual int Size { get; }
Member Description
virtual int AddItem(ItemStack stack)
virtual void Clear()
bool Contains(ItemStack stack) Whether the inventory holds at least stack.Count items of its type.
int Count(ItemStack stack) How many items of this type (and components) the inventory holds in total.
virtual ItemStack Get(int slot)
virtual int RemoveItem(ItemStack stack)
virtual void Set(int slot, ItemStack stack)
public virtual int AddItem(ItemStack stack)

Parameters

Name Type Description
stack ItemStack

Returns int

public virtual void Clear()
public bool Contains(ItemStack stack)

Whether the inventory holds at least stack.Count items of its type.

Parameters

Name Type Description
stack ItemStack The stack to look for.

Returns bool: True when it does.

public int Count(ItemStack stack)

How many items of this type (and components) the inventory holds in total.

Parameters

Name Type Description
stack ItemStack The stack to look for (its count is ignored).

Returns int: The total count.

public virtual ItemStack Get(int slot)

Parameters

Name Type Description
slot int

Returns ItemStack

public virtual int RemoveItem(ItemStack stack)

Parameters

Name Type Description
stack ItemStack

Returns int

public virtual void Set(int slot, ItemStack stack)

Parameters

Name Type Description
slot int
stack ItemStack

Throws

  • System.ArgumentException: The stack is not valid (unknown item, count above the stack size, a component that does not convert), or the slot does not exist.

IInventory · ItemStack