IInventory
Namespace Mc.Scripting.Inventories · Kind interface
public interface IInventoryA list of item slots: a player’s inventory, a chest, a plugin menu. Every read returns a copy of the stack in the slot and every write replaces the stack: no object aliases the engine’s storage, so a stack can be kept and a slot can change under it without harm. Slots count from 0. Tick thread only.
Properties
Section titled “Properties”| Member | Description |
|---|---|
IEnumerable<ItemStack> Contents { get; } |
Every slot in order (a snapshot). |
int Size { get; } |
The number of slots. |
Contents
Section titled “Contents”IEnumerable<ItemStack> Contents { get; }Every slot in order (a snapshot).
int Size { get; }The number of slots.
Methods
Section titled “Methods”| Member | Description |
|---|---|
int AddItem(ItemStack stack) |
Adds a stack, merging into existing stacks first and then filling free slots. |
void Clear() |
Empties every slot. |
ItemStack Get(int slot) |
Reads a slot. |
int RemoveItem(ItemStack stack) |
Removes items of the stack’s type (and components) from the slots. |
void Set(int slot, ItemStack stack) |
Replaces a slot. |
AddItem
Section titled “AddItem”int AddItem(ItemStack stack)Adds a stack, merging into existing stacks first and then filling free slots.
Parameters
| Name | Type | Description |
|---|---|---|
stack |
ItemStack |
The stack (the count may exceed the stack size: it is split). |
Returns int: How many items did not fit.
void Clear()Empties every slot.
ItemStack Get(int slot)Reads a slot.
Parameters
| Name | Type | Description |
|---|---|---|
slot |
int |
The slot index. |
Returns ItemStack: The stack (empty for an empty slot).
RemoveItem
Section titled “RemoveItem”int RemoveItem(ItemStack stack)Removes items of the stack’s type (and components) from the slots.
Parameters
| Name | Type | Description |
|---|---|---|
stack |
ItemStack |
What to remove. |
Returns int: How many items were removed.
void Set(int slot, ItemStack stack)Replaces a slot.
Parameters
| Name | Type | Description |
|---|---|---|
slot |
int |
The slot index. |
stack |
ItemStack |
The new content. |