EngineInventory
Namespace Mc.Scripting.Inventories · Kind class (abstract)
public abstract class EngineInventory : IInventoryShared 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.
Properties
Section titled “Properties”| 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; } |
Contents
Section titled “Contents”public IEnumerable<ItemStack> Contents { get; }Exists
Section titled “Exists”public bool Exists { get; }Whether the inventory still exists (a destroyed block entity or a closed player has none).
public virtual int Size { get; }Methods
Section titled “Methods”| 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) |
AddItem
Section titled “AddItem”public virtual int AddItem(ItemStack stack)Parameters
| Name | Type | Description |
|---|---|---|
stack |
ItemStack |
Returns int
public virtual void Clear()Contains
Section titled “Contains”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
RemoveItem
Section titled “RemoveItem”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.