Skip to content

NestedNBTHolderMap

A mutable map of nested NBTHolders, keyed by String, declared via NBTHolder.nestedMapField. Each entry is itself a self-contained, independently field()-declared NBTHolder rather than one shared value shape - useful when a map's entries are heterogeneous (e.g. one holder type per registry-driven "kind" of thing an entry represents), which NBTHolder.mapField can't express since it needs one fixed, kotlinx.serialization-compatible value type for every entry. T is the common upper bound every entry shares - plain NBTHolder itself if entries have nothing more specific in common, or a narrower shared supertype (a caller can still insert any subtype of T via getOrPut's own type parameter) - so callers get correctly-typed entries back without a manual cast at every read site.

Structural changes (getOrPut, remove) mark the owning holder dirty/resynced automatically. Mutating an existing entry's own field in place does not - call touch afterward.

Properties

keys

val keys: Set<String>

size

val size: Int

Functions

clear

fun clear()

containsKey

get

operator fun get(key: String): T?

getOrPut

fun <R : T> getOrPut(key: String, factory: () -> R): R

Returns the existing nested holder at key, or builds one via factory, stores it, and marks this dirty.

iterator

open operator override fun iterator(): Iterator<Map.Entry<String, T>>

remove

fun remove(key: String): T?

Removes and returns the nested holder at key, marking this dirty - null if it wasn't present.

touch

fun touch()

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