The layout of a block NBT file (.nbt2)
struct Block {
signature: u32
root_tag: ...
}
signature
should equal 0x4E425449root_tag
is either compound tag or array tag- Little-Endian
The layout of an inline NBT sequence.
struct Inline {
length: var32
tags: ...
}
length
is the length oftags
tags
is an array of any tag- Big-Endian
The layout of a NBT2 wireframe file.
struct Wireframe {
length: var32
names: String[]
transformation: u8[]
}
length
is the length ofnames
transformation
represents a set of wireframe bytecode instructions
The layout of a string.
struct String {
length: var32
characters: u8[]
}
length
is the length ofcharacters
1characters
is an array of modified UTF-8 characters
The layout of a tag.
struct Tag {
type: u8
name_index: var32
value: ...
}
type
follows the bit flags specified under Typename_index
is an index into the name tablevalue
is dependent on the bits set intype
const FALSE = 0b0000_0000 ; no value
const TRUE = 0b0000_0001 ; no value
const BYTE = 0b0000_0010 ; signed 8-bit integer
const SHORT = 0b0000_0011 ; signed 16-bit integer
const INT = 0b0000_0100 ; signed 32-bit integer
const LONG = 0b0000_0101 ; signed 64-bit integer
const FLOAT = 0b0000_0110 ; single-precision floating point integer
const DOUBLE = 0b0000_0111 ; double-precision floating point integer
const STRING = 0b0000_1000 ; String
const COMPOUND = 0b0000_1001 ; length-prefixed sequence of NBT2 tags (prefix: var32)
const VARINT = 0b0000_1010 ; variable-length 32-bit integer
const VARLONG = 0b0000_1011 ; variable-length 64-bit integer
const ARRAY = 0b0001_0000
const UNSIGNED = 0b0010_0000
const RESERVED = 0b0100_0000
const RESERVED = 0b1000_0000
Footnotes
-
All variable-length integers are encoded as "imperial varints," proposed as part of A better varint by Douglas Creager. ↩