Skip to content

API reference Obsidian.API.Inventory

Item class

A kind of item, like a diamond or a bow, which item stacks hold. Vanilla's items are the static properties of ItemsRegistry; plugins register more with IPluginRegistry.RegisterItem.

public sealed class Item : INetworkSerializable<Item>

In Obsidian.API.

Remarks

There is one instance per item, so items compare by reference. An item is plain data owned by the server: a plugin's item keeps its instance, identifier and id when the plugin reloads, and only its Item.Behavior is replaced.

Properties

Block

public BlockType Block { get; }

The plugin block the item places, or null. Vanilla's items place the block with their identifier.

DefaultComponents

public ImmutableArray<DataComponent> DefaultComponents { get; }

A plugin item's default components besides its stack size, durability and enchantability (see ItemProperties): every new stack of the item has them unless it sets or removes its own. They aren't sent or saved with stacks, as clients and saves know them from the item, like vanilla's. Empty for vanilla items, whose defaults Obsidian reads from vanilla's data.

Remarks

Stacks take them as they're made, so a reload that changes them reaches stacks made, loaded or received afterwards. They stay when the plugin unloads, with the item.

Enchantable

public int Enchantable { get; }

The item's default minecraft:enchantable value (higher values give better enchantments), or 0 when the item can't be enchanted.

Id

public short Id { get; }

The item's network id. Vanilla's come first, in vanilla's order; plugins' follow, in the order they were first registered.

MaxDamage

public int MaxDamage { get; }

The item's default minecraft:max_damage, or 0 when the item can't be damaged.

MaxStackSize

public int MaxStackSize { get; }

The item's default minecraft:max_stack_size.

Owner

public IPluginContainer Owner { get; }

The plugin that registered the item and provides its behaviour, or null for vanilla items and while the plugin is unloaded.

UnlocalizedName

public string UnlocalizedName { get; }

The item's identifier, like minecraft:diamond.

Methods

public static Item Read(INetStreamReader reader);public override string ToString();public static void Write(Item value, INetStreamWriter writer);

On this page