The Best Resource for Minecraft
The Best Resource for Minecraft

Een .nbt-structuur slaat paletindexen op, geen bloknamen — daarom is het zo klein

Een .nbt-structuur slaat paletindexen op, geen bloknamen — daarom is het zo klein

Drie sleutels bevatten een compleet bouwwerk: size, palette en blocks. Elk blok is een integer die naar het palet verwijst, dus een 32³-volume steen kost één string en 32,768 getallen.

A .nbt structure file — the thing a structure block saves and a datapack ships — is a much simpler format than it looks from the outside. Everything a build needs sits in a handful of top-level keys, and one design decision explains why the files are as small as they are.

De drie sleutels die het bouwwerk dragen

size     [x, y, z]                       — a list of exactly three integers
palette  [ { Name, Properties } … ]      — every DISTINCT block state, once
blocks   [ { pos, state, nbt } … ]       — one entry per placed block

palette holds each distinct block state exactly once. Een vermelding is een Name — the block id, like minecraft:oak_stairs — plus an optional Properties compound holding its blockstate, such as facing: north and half: bottom.

blocks never repeats a name. Elke vermelding bevat een pos of three integers and a state, and state is an index in het palet, geen blok-id. Eikenhouten trappen gericht naar het noorden zijn eenmalig stringdata, en elke trap daarna is een kleine integer.

Dat is de hele truc. Een volume van 32 × 32 × 32 gewone steen is één paletvermelding en 32,768 indexnummers — geen 32,768 kopieën van het woord minecraft:stone. The palette grows with how many verschillende dingen waarmee je hebt gebouwd, en de blokkenlijst groeit met hoe groot je hebt gebouwd. Dat zijn heel verschillende getallen, en slechts één ervan is meestal groot.

Twee gevolgen om rekening mee te houden bij het ontwerpen

Blockstates vermenigvuldigen je palet, niet je blokkenlijst. Eikenhouten trappen zijn niet één paletitem — ze zijn er één per daadwerkelijk gebruikte oriëntatie. Gericht in vier richtingen, boven- en onderhelft, recht en zowel binnen- als buitenhoeken: hetzelfde blok kan een dozijn paletvakken innemen. Een detailrijk bouwwerk heeft dus een groot palet en een eenvoudig bouwwerk niet, ongeacht de grootte.

Alleen geplaatste blokken krijgen een vermelding. De blokkenlijst is een lijst, geen compacte 3D-array, en een vermelding die er niet is, is er simpelweg niet — de viewer op deze pagina vult zijn raster met -1 and treats a missing coordinate as nothing placed. A hollow build is genuinely cheaper to store than a solid one of the same dimensions.

nbt is per-block and optional

Elke vermelding in blocks may carry its own nbt compound, and most do not. This is where a chest's contents, a sign's text, a spawner's mob and a banner's patterns live — attached to the individual block rather than to the palette.

Het onderscheid is belangrijk: paletgegevens worden gedeeld en blokgegevens niet. Twee kisten zijn één paletvermelding, omdat ze dezelfde blokstatus hebben — maar elk behoudt zijn eigen inventaris in zijn eigen nbt. Change the block state and you touch the palette; change what is inside it and you touch one entry in the block list.

Eén laag tegelijk lezen

De viewer hier is bewust 2D. Om laag y te tekenen, doorloopt deze de blokkenlijst, behoudt vermeldingen waarvan pos[1] equals y, en zoekt van elk de state up in the palette. That is the entire algorithm, and it is worth knowing because it is also how you would inspect one of these files yourself: there is no spatial index to build and no decompression beyond the gzip wrapper. The format is a flat list you filter.

Wat ook betekent dat een structuurbestand je niets vertelt over waar het thuishoort in een wereld. size is a bounding box and pos values are relative to its corner. The placement is the structure block's business, not the file's.

Probeer de tool: Structure & NBT Component Tools →