Skip to content

Named Binary Tag (NBT)

endstone.nbt

Classes relating to the NBT data format.

Classes:

Name Description
ByteArrayTag
ByteTag
CompoundTag
DoubleTag
FloatTag
IntArrayTag
IntTag
ListTag
LongTag
ShortTag
StringTag
Tag

Functions:

Name Description
load

Deserialize binary NBT data into a tag.

ByteArrayTag

ByteArrayTag()
ByteArrayTag(iterable: Iterable)
ByteArrayTag(buffer: Buffer)

Bases: Tag

Methods:

Name Description
append
clear
dump

Serialize this tag to binary NBT format.

extend

append

append(value: int) -> None

clear

clear() -> None

dump

dump(
    name: str | None = None,
    byte_order: Literal["little", "big"] = "little",
    network: bool = False,
) -> bytes

Serialize this tag to binary NBT format.

Parameters:

Name Type Description Default
name str | None

Optional root tag name. If None, an empty name is used.

None
byte_order Literal['little', 'big']

Byte order for encoding, either 'little' (Bedrock) or 'big' (Java).

'little'
network bool

If True, use Bedrock network varint encoding for lengths and Int/Long values.

False

Returns:

Name Type Description
bytes bytes

The binary NBT data.

extend

extend(iterable: Iterable) -> None

ByteTag

ByteTag()
ByteTag(value: int)

Bases: Tag

Methods:

Name Description
dump

Serialize this tag to binary NBT format.

Attributes:

Name Type Description
value int

value property

value: int

dump

dump(
    name: str | None = None,
    byte_order: Literal["little", "big"] = "little",
    network: bool = False,
) -> bytes

Serialize this tag to binary NBT format.

Parameters:

Name Type Description Default
name str | None

Optional root tag name. If None, an empty name is used.

None
byte_order Literal['little', 'big']

Byte order for encoding, either 'little' (Bedrock) or 'big' (Java).

'little'
network bool

If True, use Bedrock network varint encoding for lengths and Int/Long values.

False

Returns:

Name Type Description
bytes bytes

The binary NBT data.

CompoundTag

CompoundTag()
CompoundTag(mapping: dict)

Bases: Tag

Methods:

Name Description
clear
dump

Serialize this tag to binary NBT format.

items
keys
pop
setdefault
to_dict
values

clear

clear() -> None

dump

dump(
    name: str | None = None,
    byte_order: Literal["little", "big"] = "little",
    network: bool = False,
) -> bytes

Serialize this tag to binary NBT format.

Parameters:

Name Type Description Default
name str | None

Optional root tag name. If None, an empty name is used.

None
byte_order Literal['little', 'big']

Byte order for encoding, either 'little' (Bedrock) or 'big' (Java).

'little'
network bool

If True, use Bedrock network varint encoding for lengths and Int/Long values.

False

Returns:

Name Type Description
bytes bytes

The binary NBT data.

items

items() -> Iterator[tuple[str, Tag]]

keys

keys() -> Iterator[str]

pop

pop(key: str) -> Tag
pop(key: str, default: object = None) -> object

setdefault

setdefault(key: str, default: Tag) -> Tag

to_dict

to_dict() -> dict

values

values() -> Iterator[Tag]

DoubleTag

DoubleTag()
DoubleTag(value: float)

Bases: Tag

Methods:

Name Description
dump

Serialize this tag to binary NBT format.

Attributes:

Name Type Description
value float

value property

value: float

dump

dump(
    name: str | None = None,
    byte_order: Literal["little", "big"] = "little",
    network: bool = False,
) -> bytes

Serialize this tag to binary NBT format.

Parameters:

Name Type Description Default
name str | None

Optional root tag name. If None, an empty name is used.

None
byte_order Literal['little', 'big']

Byte order for encoding, either 'little' (Bedrock) or 'big' (Java).

'little'
network bool

If True, use Bedrock network varint encoding for lengths and Int/Long values.

False

Returns:

Name Type Description
bytes bytes

The binary NBT data.

FloatTag

FloatTag()
FloatTag(value: float)

Bases: Tag

Methods:

Name Description
dump

Serialize this tag to binary NBT format.

Attributes:

Name Type Description
value float

value property

value: float

dump

dump(
    name: str | None = None,
    byte_order: Literal["little", "big"] = "little",
    network: bool = False,
) -> bytes

Serialize this tag to binary NBT format.

Parameters:

Name Type Description Default
name str | None

Optional root tag name. If None, an empty name is used.

None
byte_order Literal['little', 'big']

Byte order for encoding, either 'little' (Bedrock) or 'big' (Java).

'little'
network bool

If True, use Bedrock network varint encoding for lengths and Int/Long values.

False

Returns:

Name Type Description
bytes bytes

The binary NBT data.

IntArrayTag

IntArrayTag()
IntArrayTag(iterable: Iterable)

Bases: Tag

Methods:

Name Description
append
clear
dump

Serialize this tag to binary NBT format.

extend

append

append(value: int) -> None

clear

clear() -> None

dump

dump(
    name: str | None = None,
    byte_order: Literal["little", "big"] = "little",
    network: bool = False,
) -> bytes

Serialize this tag to binary NBT format.

Parameters:

Name Type Description Default
name str | None

Optional root tag name. If None, an empty name is used.

None
byte_order Literal['little', 'big']

Byte order for encoding, either 'little' (Bedrock) or 'big' (Java).

'little'
network bool

If True, use Bedrock network varint encoding for lengths and Int/Long values.

False

Returns:

Name Type Description
bytes bytes

The binary NBT data.

extend

extend(iterable: Iterable) -> None

IntTag

IntTag()
IntTag(value: int)

Bases: Tag

Methods:

Name Description
dump

Serialize this tag to binary NBT format.

Attributes:

Name Type Description
value int

value property

value: int

dump

dump(
    name: str | None = None,
    byte_order: Literal["little", "big"] = "little",
    network: bool = False,
) -> bytes

Serialize this tag to binary NBT format.

Parameters:

Name Type Description Default
name str | None

Optional root tag name. If None, an empty name is used.

None
byte_order Literal['little', 'big']

Byte order for encoding, either 'little' (Bedrock) or 'big' (Java).

'little'
network bool

If True, use Bedrock network varint encoding for lengths and Int/Long values.

False

Returns:

Name Type Description
bytes bytes

The binary NBT data.

ListTag

ListTag()
ListTag(iterable: Iterable)

Bases: Tag

Methods:

Name Description
append
clear
dump

Serialize this tag to binary NBT format.

empty
extend
pop
size
to_list

append

append(tag: Tag) -> None

clear

clear() -> None

dump

dump(
    name: str | None = None,
    byte_order: Literal["little", "big"] = "little",
    network: bool = False,
) -> bytes

Serialize this tag to binary NBT format.

Parameters:

Name Type Description Default
name str | None

Optional root tag name. If None, an empty name is used.

None
byte_order Literal['little', 'big']

Byte order for encoding, either 'little' (Bedrock) or 'big' (Java).

'little'
network bool

If True, use Bedrock network varint encoding for lengths and Int/Long values.

False

Returns:

Name Type Description
bytes bytes

The binary NBT data.

empty

empty() -> bool

extend

extend(iterable: Iterable) -> None

pop

pop(index: int = -1) -> Tag

size

size() -> int

to_list

to_list() -> list

LongTag

LongTag()
LongTag(value: int)

Bases: Tag

Methods:

Name Description
dump

Serialize this tag to binary NBT format.

Attributes:

Name Type Description
value int

value property

value: int

dump

dump(
    name: str | None = None,
    byte_order: Literal["little", "big"] = "little",
    network: bool = False,
) -> bytes

Serialize this tag to binary NBT format.

Parameters:

Name Type Description Default
name str | None

Optional root tag name. If None, an empty name is used.

None
byte_order Literal['little', 'big']

Byte order for encoding, either 'little' (Bedrock) or 'big' (Java).

'little'
network bool

If True, use Bedrock network varint encoding for lengths and Int/Long values.

False

Returns:

Name Type Description
bytes bytes

The binary NBT data.

ShortTag

ShortTag()
ShortTag(value: int)

Bases: Tag

Methods:

Name Description
dump

Serialize this tag to binary NBT format.

Attributes:

Name Type Description
value int

value property

value: int

dump

dump(
    name: str | None = None,
    byte_order: Literal["little", "big"] = "little",
    network: bool = False,
) -> bytes

Serialize this tag to binary NBT format.

Parameters:

Name Type Description Default
name str | None

Optional root tag name. If None, an empty name is used.

None
byte_order Literal['little', 'big']

Byte order for encoding, either 'little' (Bedrock) or 'big' (Java).

'little'
network bool

If True, use Bedrock network varint encoding for lengths and Int/Long values.

False

Returns:

Name Type Description
bytes bytes

The binary NBT data.

StringTag

StringTag()
StringTag(value: str)

Bases: Tag

Methods:

Name Description
dump

Serialize this tag to binary NBT format.

Attributes:

Name Type Description
value str

value property

value: str

dump

dump(
    name: str | None = None,
    byte_order: Literal["little", "big"] = "little",
    network: bool = False,
) -> bytes

Serialize this tag to binary NBT format.

Parameters:

Name Type Description Default
name str | None

Optional root tag name. If None, an empty name is used.

None
byte_order Literal['little', 'big']

Byte order for encoding, either 'little' (Bedrock) or 'big' (Java).

'little'
network bool

If True, use Bedrock network varint encoding for lengths and Int/Long values.

False

Returns:

Name Type Description
bytes bytes

The binary NBT data.

Tag

load

load(
    data: bytes,
    byte_order: Literal["little", "big"] = "little",
    network: bool = False,
) -> tuple[Tag, str]

Deserialize binary NBT data into a tag.

Parameters:

Name Type Description Default
data bytes

Binary NBT data (bytes).

required
byte_order Literal['little', 'big']

Byte order of the binary data, either 'little' (Bedrock) or 'big' (Java).

'little'
network bool

If True, expect Bedrock network varint encoding.

False

Returns:

Type Description
tuple[Tag, str]

tuple[Tag, str]: A tuple of (tag, name) where name is the root tag name.