Skip to content

NestedNBTHolderList

A dynamically-sized, index-ordered list of nested NBTHolders, declared via NBTHolder.nestedListField. Like NestedNBTHolderMap, entries can be heterogeneous - add takes its own factory, and reconstructing a saved entry inspects that entry's own raw sub-CompoundTag first (the same factory shape NBTHolder.nestedListField itself takes) to decide which concrete holder type to rebuild. T is the common upper bound every entry shares - see NestedNBTHolderMap's KDoc for why that's still useful even for a genuinely heterogeneous list.

Persisted as an NbtCompound keyed by stringified index, not a genuine NBT list - see ArchieStorageList's KDoc for why (the same reasoning applies: every entry is its own sub-CompoundTag, but a raw NBT ListTag requires one uniform concrete tag type, which knbt only exposes a public builder API for when that's statically known).

Properties

size

val size: Int

Functions

add

fun <R : T> add(factory: () -> R): R

Builds a new entry via factory, appends it, and marks this dirty.

clear

fun clear()

get

operator fun get(index: Int): T

iterator

open operator override fun iterator(): Iterator<T>

removeAt

fun removeAt(index: Int): T

Removes and returns the entry at index, marking this dirty.

touch

fun touch()

Marks this dirty without a structural change - call after mutating an existing entry's own field(s) in place.