A simple and fast implementation of NBT written in Python 3.
To use XNBT you need to have Python >= 3.7.x pre-installed.
To install XNBT, download or clone the repository:
git clone https://github.com/MCPI-Devs/xnbt.gitThere are no aditional requirements.
- 100% NBT compatible
 - Basic pretty-print as JSON
 - Zlib and GZip compression support
 - Big- and Little-endian support
 
You can use the API and, additionally, you can run the xnbt.py file in the root of the repo as:
xnbt.py file mode
Where file is a NBT file and mode is a data mode. It will pretty-print the parsed file as JSON.
Constructor of the XNBT main class. The mode argument is a data mode.
Parses data and returns a dict object containing all the tags in the following format:
{
    "type": TAG_Type,
    "name": TAG_Name | None,
    "content": [TAG_Childs] | TAG_Content
}
Returns tag packed into binary format.
An exception raised when a parsing error occurs. Other exceptions such as OSError, gzip.BadGZipFile, EOFError and zlib.error can be raised if a compression/decompression error occurs.
A mode is a combination of the following characters:
Enidanness
l: Little-endianb: Big-endiann: Network default (big-endian)
Compression:
u: Uncompressedz: Zlib compression (DEFLATE)g: GZip compression (DEFLATE)
Container format:
r: Rawo: Old level.date: Old entities.dat
For an example, a xnbt.XNBT(mode="bgo") class manipulates the data as a big-endian, GZip-compressed level.dat file.
All the code of this project is licensed under the GNU General Public License version 2.0 (GPL-2.0).
All the documentation of this project is licensed under the Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.
