ItemRegistry
Namespace Mc.Scripting.Content · Kind class (sealed)
public sealed class ItemRegistryRegisters custom items.
Properties
Section titled “Properties”| Member | Description |
|---|---|
IReadOnlyList<CustomItem> All { get; } |
Every registered item (a snapshot). |
public IReadOnlyList<CustomItem> All { get; }Every registered item (a snapshot).
Methods
Section titled “Methods”| Member | Description |
|---|---|
ItemStack Create(string id, int count = 1) |
A stack of a registered item. |
CustomItem? Get(string id) |
The registered item with this id. |
CustomItem? Of(ItemStack stack) |
The definition of a stack that is a registered custom item. |
void Register(CustomItem item) |
Registers an item for the plugin whose code is running (released when the plugin unloads). |
Create
Section titled “Create”public ItemStack Create(string id, int count = 1)A stack of a registered item.
Parameters
| Name | Type | Description |
|---|---|---|
id |
string |
The id. |
count |
int = 1 |
The stack size. |
Returns ItemStack: The stack, or ItemStack.Empty when no such item is registered.
public CustomItem? Get(string id)The registered item with this id.
Parameters
| Name | Type | Description |
|---|---|---|
id |
string |
The id. |
Returns CustomItem?: The definition, or null.
public CustomItem? Of(ItemStack stack)The definition of a stack that is a registered custom item.
Parameters
| Name | Type | Description |
|---|---|---|
stack |
ItemStack |
The stack. |
Returns CustomItem?: The definition, or null for an ordinary stack (or an item whose plugin is not loaded).
Register
Section titled “Register”public void Register(CustomItem item)Registers an item for the plugin whose code is running (released when the plugin unloads).
Parameters
| Name | Type | Description |
|---|---|---|
item |
CustomItem |
The definition. |
Throws
System.InvalidOperationException: The id is taken by another plugin, or no plugin code is running.