NBT¶
Quarry implements the Named Binary Tag (NBT) format. The following tag types
are available from the quarry.types.nbt module:
| Class | Value type |
|---|---|
TagByte |
int |
TagShort |
int |
TagInt |
int |
TagLong |
int |
TagFloat |
float |
TagDouble |
float |
TagByteArray |
PackedArray with 8-bit sectors |
TagIntArray |
PackedArray with 32-bit sectors |
TagLongArray |
PackedArray with 64-bit sectors |
TagString |
str (py3) or unicode (py2) |
TagList |
list of tags. |
TagCompound |
dict of names and tags. |
TagRoot |
dict containing a single name and tag. |
Note
Unlike some other NBT libraries, a tag’s name is stored by its parent -
either a TagRoot or a TagCompound. A tag when considered alone is
always nameless.
Tags¶
All tag types have the following attributes and methods:
-
Tag.__init__(value)¶ Creates a tag object from the given value.
-
classmethod
Tag.from_bytes(bytes)¶ Creates a tag object from data at the beginning of the supplied byte string.
-
classmethod
Tag.from_buff(buff)¶ Creates a tag object from data at the beginning of the supplied
Bufferobject.
-
Tag.to_obj()¶ Returns a friendly representation of the tag using only basic Python datatypes. This is a lossy operation, as Python has fewer data types than NBT.
-
Tag.to_bytes()¶ Returns a packed version of the tag as a byte string.
-
Tag.value¶ The value of the tag.
When working with NBT in relation to a Protocol,
the Buffer.unpack_nbt() and Buffer.pack_nbt() methods may be
helpful.
Files¶
You can open an NBT file using the NBTFile class.
You can open Minecraft 1.13+ world files (.mca) using the RegionFile
class, which can also function as a context manager. See Blocks and Chunks for
information on loading block and light data.