Download Latest Version NBTSharp.zip (34.4 kB)
Email in envelope

Get an email when there's a new version of NBTSharp

Home
Name Modified Size InfoDownloads / Week
NBTSharp.zip 2014-05-11 34.4 kB
readme.txt 2014-05-11 2.2 kB
NBTSharpEdit.zip 2014-05-10 26.2 kB
Totals: 3 Items   62.7 kB 0
A named binary tag library (file format used in the computer game Minecraft) for .net written in C#.

Features:
Classes representing each type of tag
NBT data file reader and writer classes
Built-in handling of endianess
Get tags from paths

Download NBTSharp.zip, extract the archive, and add NBTSharp.dll as a reference in your project, and you are ready to use NBTSharp in your program!

Code Example:

//reading bigtest
NBTFileReader reader = new NBTFileReader(@"C:\bigtest.nbt");
TagCompound root = reader.compound;

TagLong longTest = (TagLong)root.getNode(@"Level\longTest");
Console.WriteLine(longTest);

Console Output:

9223372036854775807

Reading a minecraft data file:

//map item files can be found in Minecraft\world\data
NBTFileReader reader = new NBTFileReader(@"C:\map_0.dat");
TagCompound root = reader.compound;

//the path starts with a back slash
//because the root node in a map item has no name
TagByte dimension = (TagByte)root.getNode(@"\data\dimension");
Console.WriteLine(dimension);

This will output the dimension the map is from, i.e. World, or Nether

Editing a minecraft data file:

//changing the scale in a map item file allows for different zoom levels
//reading the map item
sbyte scale = 1; //change the number here to any number above 0
NBTFileReader reader = new NBTFileReader(@"C:\map_0.dat");
TagCompound root = reader.compound;

//finding the scale tag
TagByte tagScale = (TagByte)root.getNode(@"\data\scale");

//changing the value
tagScale.number = scale;

//the file is automatically closed after the read is complete
//so we can use the nbtfilewriter to write out the compound
NBTFileWriter.write(@"C:\map_0.dat", root);

The file can now be used in Minecraft, and it will have a different scale

Reading the scale in the map file

//checking that the change was successfully made
//reading the map item
sbyte scale = 1;
NBTFileReader reader = new NBTFileReader(@"C:\map_0.dat");
TagCompound root = reader.compound;

//finding the scale tag
TagByte tagScale = (TagByte)root.getNode(@"\data\scale");
Console.WriteLine(tagScale);

Console Output:
1
Source: readme.txt, updated 2014-05-11