Skip to content

Instantly share code, notes, and snippets.

@copygirl
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save copygirl/4832c98a6d673f6fe7e1 to your computer and use it in GitHub Desktop.

Select an option

Save copygirl/4832c98a6d673f6fe7e1 to your computer and use it in GitHub Desktop.
WIP NBT library in action
static void NewExample()
{
var root = new TagCompound {
{ "name", "copygirl" },
{ "version", "0.0.1" },
{ "rating", 0.2F },
{ "mods", new TagList {
new TagCompound {
{ "name", "BetterStorage" },
{ "version", "0.9.9-eternally-unfinished" },
{ "optional", (byte)1 } },
new TagCompound {
{ "name", "InventoryTweaks" },
{ "version", "1.whatever" },
{ "optional", (byte)0 },
{ "recommended", (byte)0 },
{ "seriously dont use this", (byte)1 } }
} }
};
root.Save("test.dat", "modlist", NBTCompression.GZip);
}
static void LoadExample()
{
var player = TagBase.Load("player.dat");
foreach (var item in (TagList)player["Inventory"]) {
var slot = (byte)item["Slot"];
var count = (byte)item["Count"];
var id = (string)item["id"];
var damage = (short)item["Damage"];
Console.WriteLine("[{0,3}] {1,2}x {2}:{3}", slot, count, id, damage);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment