Literals
profile: nbt = {"name": "Alex", "health": 20, "active": True, "position": [10, 64, -4], "settings": {"particles": False}}
empty: nbt = {}
NBT arrays may contain different NBT-compatible value kinds. Keys must be string literals.
DATACRAFT V2
The nbt type stores JSON-style compound data in the namespace's Minecraft command storage. It may contain integers, booleans, strings, lists, and nested NBT compounds. Minecraft NBT has no null value, so None and entities cannot be embedded in a compound.
profile: nbt = {"name": "Alex", "health": 20, "active": True, "position": [10, 64, -4], "settings": {"particles": False}}
empty: nbt = {}
NBT arrays may contain different NBT-compatible value kinds. Keys must be string literals.
profile["health"] = 18
health: int = profile["health"]
settings: nbt = profile["settings"]
particles: bool = profile["settings"]["particles"]
NBT does not support property syntax: use profile["health"], never profile.health. Field reads need an expected type, normally supplied by a typed variable declaration.
def update(profile: nbt) -> nbt:
profile["active"] = True
return profile
Whole NBT variables can be passed to and returned from functions. Structured return data uses runtime storage because Minecraft /return itself only carries an integer result.
say(profile) displays the compound, while say(profile["name"]) displays a selected field. len(profile) returns the number of keys in the compound.