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
¶
Bases: Tag
Methods:
| Name | Description |
|---|---|
append |
|
clear |
|
dump |
Serialize this tag to binary NBT format. |
extend |
|
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'
|
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. |
ByteTag
¶
ByteTag(value: int)
Bases: Tag
Methods:
| Name | Description |
|---|---|
dump |
Serialize this tag to binary NBT format. |
Attributes:
| Name | Type | Description |
|---|---|---|
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'
|
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(mapping: dict)
Bases: Tag
Methods:
| Name | Description |
|---|---|
clear |
|
dump |
Serialize this tag to binary NBT format. |
items |
|
keys |
|
pop |
|
setdefault |
|
to_dict |
|
values |
|
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'
|
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. |
DoubleTag
¶
DoubleTag(value: float)
Bases: Tag
Methods:
| Name | Description |
|---|---|
dump |
Serialize this tag to binary NBT format. |
Attributes:
| Name | Type | Description |
|---|---|---|
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'
|
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(value: float)
Bases: Tag
Methods:
| Name | Description |
|---|---|
dump |
Serialize this tag to binary NBT format. |
Attributes:
| Name | Type | Description |
|---|---|---|
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'
|
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(iterable: Iterable)
Bases: Tag
Methods:
| Name | Description |
|---|---|
append |
|
clear |
|
dump |
Serialize this tag to binary NBT format. |
extend |
|
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'
|
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. |
IntTag
¶
IntTag(value: int)
Bases: Tag
Methods:
| Name | Description |
|---|---|
dump |
Serialize this tag to binary NBT format. |
Attributes:
| Name | Type | Description |
|---|---|---|
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'
|
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(iterable: Iterable)
Bases: Tag
Methods:
| Name | Description |
|---|---|
append |
|
clear |
|
dump |
Serialize this tag to binary NBT format. |
empty |
|
extend |
|
pop |
|
size |
|
to_list |
|
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'
|
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. |
LongTag
¶
LongTag(value: int)
Bases: Tag
Methods:
| Name | Description |
|---|---|
dump |
Serialize this tag to binary NBT format. |
Attributes:
| Name | Type | Description |
|---|---|---|
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'
|
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(value: int)
Bases: Tag
Methods:
| Name | Description |
|---|---|
dump |
Serialize this tag to binary NBT format. |
Attributes:
| Name | Type | Description |
|---|---|---|
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'
|
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(value: str)
Bases: Tag
Methods:
| Name | Description |
|---|---|
dump |
Serialize this tag to binary NBT format. |
Attributes:
| Name | Type | Description |
|---|---|---|
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'
|
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'
|
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. |