Skip to main content

Module binary

Module binary 

Source
Expand description

The binary form — what the build compiles content to and the runtime and the Java hosts read, like NBT:

"YOGD" version:u8
strings: varint count, then each as varint length + UTF-8
root value

A value is a tag byte and its payload; every string (map keys too) is an index into the table, so repeated keys and ids cost one varint each.

TagValuePayload
0null—
1, 2false, true—
3intzigzag varint
4floatf64, little-endian
5stringstring
6listvarint count, values
7mapvarint count, (key string, value) pairs
8refkind string, id string
9tagkind string, id string
10resourceset string, key string
11textstring
12imagestring
13coloru32, little-endian (0xAARRGGBB)
14translation keystring

Varints are LEB128. Decoding checks every length against the input, so malformed bytes are an error, never a panic or a huge allocation.

Structs§

DecodeError
Malformed binary data.

Constants§

MAGIC
MAX_DEPTH
Nested deeper than this is malformed.
VERSION

Functions§

decode
Reads the binary form.
encode
value in the binary form.