Skip to content

DaanV2/DaanV2.NBT.Net

Repository files navigation

DaanV2-NBT.Net

.NET Unit test 📦 Nuget Release
Nuget Version Nuget Downloads

An NBT library for reading and writing NBT files/data Nuget package

Usage

Read a file

var Compound = NBTReader.ReadFile("Path to file", Endian.Little, NBTCompression.Auto);
var age = Compound.GetChild("Age");

//Retrieve value if you know what type it should be
Int32 item = age.GetValue<Int32>();

//OR
if (age is NBTTagInt a) {
    Assert.IsTrue(a.Value == 256, "Hello set wrong")
}

//OR
if (age.TryGetValue(out Int32 item)) {
    Assert.IsTrue(item == 256, "Hello set wrong")
}

//OR
var item = Compound.GetChild<Int32>("Age");

Writes to a file

ITag Tag;

//Writes the tag to the specified file using GZIP compression and little-endian methods
NBTWriter.WriteFile("Path to file", Tag, NBTCompression.Gzip, Endian.Little);

//Writes the tag to the specified file using no compression and little-endian methods
NBTWriter.WriteFile("Path to file", Tag, Endian.Little);

Building a structure

CompoundBuilder Builder = new CompoundBuilder("Root", 10);
Builder.Add("IsDetermined", true);
Builder.Add("Amount", 5);

ITag = Builder.GetResult();

Installation

Check that the NuGet packages have been downloaded.

Dependencies:

Solved with NuGet