Skip to content

API reference Obsidian.API.Inventory.DataComponents

ComponentCodec<TValue> record

How a plugin's component type saves its values: like vanilla's DataComponentType.codec(), to the NBT stacks are saved with, under the type's identifier in their components.

public sealed record ComponentCodec<TValue> : IEquatable<ComponentCodec<TValue>>

In Obsidian.API.

Constructors

ComponentCodec(Func<TValue, INbtTag>, Func<INbtTag, TValue>)

public ComponentCodec(Func<TValue, INbtTag> Encode, Func<INbtTag, TValue> Decode);

How a plugin's component type saves its values: like vanilla's DataComponentType.codec(), to the NBT stacks are saved with, under the type's identifier in their components.

Parameters

Encode
Turns a value into its saved form; the tag's name is ignored.
Decode
Reads a value back from what Encode wrote.

Properties

Decode

public Func<INbtTag, TValue> Decode { get; init; }

Reads a value back from what Encode wrote.

Encode

public Func<TValue, INbtTag> Encode { get; init; }

Turns a value into its saved form; the tag's name is ignored.

On this page