Named Binary Tag (NBT)
endstone.nbt
¶
Classes relating to the NBT data format.
Classes:
| Name | Description |
|---|---|
ByteArrayTag |
An NBT tag holding an array of unsigned 8-bit integers. |
ByteTag |
An NBT tag holding an unsigned 8-bit integer value. |
CompoundTag |
A named NBT compound tag mapping string keys to tags. |
DoubleTag |
An NBT tag holding a 64-bit floating-point value. |
FloatTag |
An NBT tag holding a 32-bit floating-point value. |
IntArrayTag |
An NBT tag holding an array of signed 32-bit integers. |
IntTag |
An NBT tag holding a signed 32-bit integer value. |
ListTag |
An NBT list tag of homogeneously-typed tags. |
LongTag |
An NBT tag holding a signed 64-bit integer value. |
ShortTag |
An NBT tag holding a signed 16-bit integer value. |
StringTag |
An NBT tag holding a string value. |
Tag |
Base class for all NBT tag variants. |
Functions:
| Name | Description |
|---|---|
load |
Deserialize binary NBT data into a tag. |
ByteArrayTag
¶
Bases: Tag
An NBT tag holding an array of unsigned 8-bit integers.
Methods:
| Name | Description |
|---|---|
append |
Appends a value to the end of this tag. |
clear |
Removes all values from this tag. |
dump |
Serialize this tag to binary NBT format. |
extend |
Appends all values from an iterable to the end of this tag. |
append
¶
append(value: int) -> None
Appends a value to the end of this tag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
int
|
The value to append. |
required |
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
|
byte_order
|
Literal['little', 'big']
|
Byte order for encoding, either |
'little'
|
network
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bytes |
bytes
|
The binary NBT data. |
ByteTag
¶
ByteTag(value: int)
Bases: Tag
An NBT tag holding an unsigned 8-bit integer value.
Methods:
| Name | Description |
|---|---|
dump |
Serialize this tag to binary NBT format. |
Attributes:
| Name | Type | Description |
|---|---|---|
value |
int
|
The underlying value of this tag. |
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
|
byte_order
|
Literal['little', 'big']
|
Byte order for encoding, either |
'little'
|
network
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bytes |
bytes
|
The binary NBT data. |
CompoundTag
¶
CompoundTag(mapping: dict)
Bases: Tag
A named NBT compound tag mapping string keys to tags.
Methods:
| Name | Description |
|---|---|
clear |
Removes all entries from this compound tag. |
dump |
Serialize this tag to binary NBT format. |
items |
Returns an iterator over the (key, tag) pairs in this compound tag. |
keys |
Returns an iterator over the keys in this compound tag. |
pop |
|
setdefault |
Returns the tag for the given key, inserting a default if the key is not present. |
to_dict |
Converts this compound tag to a plain Python dict of native values. |
values |
Returns an iterator over the tags in this compound tag. |
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
|
byte_order
|
Literal['little', 'big']
|
Byte order for encoding, either |
'little'
|
network
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bytes |
bytes
|
The binary NBT data. |
items
¶
Returns an iterator over the (key, tag) pairs in this compound tag.
setdefault
¶
Returns the tag for the given key, inserting a default if the key is not present.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to look up. |
required |
default
|
Tag
|
The tag to insert and return if the key is not present. |
required |
Returns:
| Type | Description |
|---|---|
Tag
|
The tag associated with the key, or the newly inserted default. |
DoubleTag
¶
DoubleTag(value: float)
Bases: Tag
An NBT tag holding a 64-bit floating-point value.
Methods:
| Name | Description |
|---|---|
dump |
Serialize this tag to binary NBT format. |
Attributes:
| Name | Type | Description |
|---|---|---|
value |
float
|
The underlying value of this tag. |
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
|
byte_order
|
Literal['little', 'big']
|
Byte order for encoding, either |
'little'
|
network
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bytes |
bytes
|
The binary NBT data. |
FloatTag
¶
FloatTag(value: float)
Bases: Tag
An NBT tag holding a 32-bit floating-point value.
Methods:
| Name | Description |
|---|---|
dump |
Serialize this tag to binary NBT format. |
Attributes:
| Name | Type | Description |
|---|---|---|
value |
float
|
The underlying value of this tag. |
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
|
byte_order
|
Literal['little', 'big']
|
Byte order for encoding, either |
'little'
|
network
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bytes |
bytes
|
The binary NBT data. |
IntArrayTag
¶
IntArrayTag(iterable: Iterable)
Bases: Tag
An NBT tag holding an array of signed 32-bit integers.
Methods:
| Name | Description |
|---|---|
append |
Appends a value to the end of this tag. |
clear |
Removes all values from this tag. |
dump |
Serialize this tag to binary NBT format. |
extend |
Appends all values from an iterable to the end of this tag. |
append
¶
append(value: int) -> None
Appends a value to the end of this tag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
int
|
The value to append. |
required |
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
|
byte_order
|
Literal['little', 'big']
|
Byte order for encoding, either |
'little'
|
network
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bytes |
bytes
|
The binary NBT data. |
IntTag
¶
IntTag(value: int)
Bases: Tag
An NBT tag holding a signed 32-bit integer value.
Methods:
| Name | Description |
|---|---|
dump |
Serialize this tag to binary NBT format. |
Attributes:
| Name | Type | Description |
|---|---|---|
value |
int
|
The underlying value of this tag. |
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
|
byte_order
|
Literal['little', 'big']
|
Byte order for encoding, either |
'little'
|
network
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bytes |
bytes
|
The binary NBT data. |
ListTag
¶
ListTag(iterable: Iterable)
Bases: Tag
An NBT list tag of homogeneously-typed tags.
Methods:
| Name | Description |
|---|---|
append |
Appends a tag to the end of this list. |
clear |
Removes all tags from this list. |
dump |
Serialize this tag to binary NBT format. |
empty |
Returns |
extend |
Appends all tags from an iterable to the end of this list. |
pop |
Removes and returns the tag at the given index. |
size |
The number of tags in this list. |
to_list |
Converts this list to a plain Python list of native values. |
append
¶
append(tag: Tag) -> None
Appends a tag to the end of this list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
Tag
|
The tag to append. It must have the same type as the existing elements. |
required |
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
|
byte_order
|
Literal['little', 'big']
|
Byte order for encoding, either |
'little'
|
network
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bytes |
bytes
|
The binary NBT data. |
extend
¶
extend(iterable: Iterable) -> None
Appends all tags from an iterable to the end of this list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterable
|
Iterable
|
An iterable of tags to append. Each tag must have the same type as the existing elements. |
required |
pop
¶
LongTag
¶
LongTag(value: int)
Bases: Tag
An NBT tag holding a signed 64-bit integer value.
Methods:
| Name | Description |
|---|---|
dump |
Serialize this tag to binary NBT format. |
Attributes:
| Name | Type | Description |
|---|---|---|
value |
int
|
The underlying value of this tag. |
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
|
byte_order
|
Literal['little', 'big']
|
Byte order for encoding, either |
'little'
|
network
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bytes |
bytes
|
The binary NBT data. |
ShortTag
¶
ShortTag(value: int)
Bases: Tag
An NBT tag holding a signed 16-bit integer value.
Methods:
| Name | Description |
|---|---|
dump |
Serialize this tag to binary NBT format. |
Attributes:
| Name | Type | Description |
|---|---|---|
value |
int
|
The underlying value of this tag. |
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
|
byte_order
|
Literal['little', 'big']
|
Byte order for encoding, either |
'little'
|
network
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bytes |
bytes
|
The binary NBT data. |
StringTag
¶
StringTag(value: str)
Bases: Tag
An NBT tag holding a string value.
Methods:
| Name | Description |
|---|---|
dump |
Serialize this tag to binary NBT format. |
Attributes:
| Name | Type | Description |
|---|---|---|
value |
str
|
The underlying value of this tag. |
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
|
byte_order
|
Literal['little', 'big']
|
Byte order for encoding, either |
'little'
|
network
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bytes |
bytes
|
The binary NBT data. |
Tag
¶
Base class for all NBT tag variants.
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 |
False
|
Returns:
| Type | Description |
|---|---|
tuple[Tag, str]
|
tuple[Tag, str]: A tuple of (tag, name) where name is the root tag name. |