Home

Tertrih Fertray

Project Admins:

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

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

MongoDB Logo MongoDB