Package-level declarations

The main and public NBT serialization API

Types

Link copied to clipboard
sealed class Nbt

Instances of this class can encode values to Tags and decode Tags to values.

Link copied to clipboard
class NbtBuilder(from: Nbt)
Link copied to clipboard
data class NbtConfig(val encodeDefaults: Boolean = false, val ignoreUnknownKeys: Boolean = false)
Link copied to clipboard
class UnknownKeyException(val key: String) : SerializationException

Thrown if NbtConfig.ignoreUnknownKeys is set to false and an unknown key is present during deserialization.

Functions

Link copied to clipboard
inline fun <T> Nbt.decodeFromNbtElement(element: Tag): T

Encodes the given element to an instance of the class T.

Link copied to clipboard
inline fun <T> Nbt.encodeToNbtElement(value: T): Tag

Encodes the given value to an Tag. If the given value of the type T can be represented by a primitive NbtElement, such an element will be the result of this function. Otherwise, an net.minecraft.nbt.CompoundTag will be created.

Link copied to clipboard
inline fun Nbt(from: Nbt = Nbt.Default, build: NbtBuilder.() -> Unit): Nbt

Creates a new instace of Nbt. This function allows you to customize the behaviour of NBT serialization and deserialization.