Code Monkey home page Code Monkey logo

xnbt's Introduction

XNBT

A simple and fast implementation of NBT written in Python 3.

Getting started

Prerequisites

To use XNBT you need to have Python >= 3.7.x pre-installed.

Installation

To install XNBT, download or clone the repository:

git clone https://github.com/MCPI-Devs/xnbt.git

There are no aditional requirements.

Features

  • 100% NBT compatible
  • Basic pretty-print as JSON
  • Zlib and GZip compression support
  • Big- and Little-endian support

Usage

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.

API

class xnbt.XNBT(mode="lzr")

Constructor of the XNBT main class. The mode argument is a data mode.

def xnbt.XNBT.parse(data)

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
}

def xnbt.XNBT.build(tag)

Returns tag packed into binary format.

exception xnbt.NBTParsingError

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.

Data modes

A mode is a combination of the following characters:

Enidanness

  • l: Little-endian
  • b: Big-endian
  • n: Network default (big-endian)

Compression:

  • u: Uncompressed
  • z: Zlib compression (DEFLATE)
  • g: GZip compression (DEFLATE)

Container format:

  • r: Raw
  • o: Old level.dat
  • e: Old entities.dat

For an example, a xnbt.XNBT(mode="bgo") class manipulates the data as a big-endian, GZip-compressed level.dat file.

Licensing

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.

CC BY-SA 4.0

xnbt's People

Contributors

timendum avatar torralbaa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

wendellmeset

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.