Skip to content
/ nbt Public

Flexible and intuitive Java NBT library, with emphasis on custom tags.

License

Notifications You must be signed in to change notification settings

BitBuf/nbt

Repository files navigation

nbt

Flexible and intuitive library for reading and writing Minecraft's NBT format.

OverviewUsageFeaturesJavadocsLicense

Overview

NBT (Named Binary Tag) is a binary format devised by Notch to be Minecraft's primary means of data storage.

There are 12 types of tag that can be used in a complaint NBT file (see TagType.java for descriptions of each):

All valid NBT structures begin with a compound tag; the root compound. Everything else in the NBT structure is a child of this root compound.

Usage

This library can be added as a dependency via maven central:

repositories {
    mavenCentral()
}

dependencies {
    implementation "dev.dewy:nbt:1.3.0"
}

NBTReader Sample: Base64

The Nbt class can be used to easily (de)serialize NBT data:

public static final Nbt NBT = new Nbt();
CompoundTag test = NBT.fromBase64("CgALaGVsbG8gd29ybGQDAAR0ZXN0AAAAAAA");

System.out.println(test.getName()); // hello world
System.out.println(test.<IntTag>get("test").getValue()); // 0

See the NbtTest class for full sample usage.

Features

  • Fully compliant with Mojang's "standards"
  • Small and lightweight (36Kb!)
  • Supports all Java edition NBT tags (including long array)
  • Intuitive and flexible reading and writing functionality

Planned

  • SNBT (Stringified NBT) support
  • ENBT (Extended NBT) format (missing data types e.g., double array) support
  • JSON (De)serialization

Javadocs

Javadocs for the library can be found here.

License

This project is licensed under the MIT license: see here.