https://github.com/deniz-blue/netherite.nbt
Modern C# NBT (Named Binary Tag) library
https://github.com/deniz-blue/netherite.nbt
nbt nbt-files nbt-format nbt-library nbt-parser netherite
Last synced: 9 months ago
JSON representation
Modern C# NBT (Named Binary Tag) library
- Host: GitHub
- URL: https://github.com/deniz-blue/netherite.nbt
- Owner: deniz-blue
- Created: 2022-06-09T13:53:35.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-02-25T05:59:43.000Z (over 3 years ago)
- Last Synced: 2025-08-14T04:48:12.943Z (10 months ago)
- Topics: nbt, nbt-files, nbt-format, nbt-library, nbt-parser, netherite
- Language: C#
- Homepage:
- Size: 1.3 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MineSharp.Nbt
This is the "fork" of fNbt (90% rewritten so idk if its called a fork anymore)
[Named Binary Tag (NBT)](https://minecraft.gamepedia.com/NBT_format) library for modern C#
## Features:
- Implicit casts and initializer syntax allow for better code (example below)
- Non-complicated straightforward API:
- `NbtDocument.FromBinary(byte[])`
- `NbtDocument.FromBinary(Stream)`
- `byte[] NbtDocument.ToBinary()`
- Newtonsoft.JSON-like `NbtConvert`
- gzip + zlib support
## TODO
- endian support
- more docs
## EXAMPLES
### Implicit casts and initializer syntax
```cs
```
#### Accessing tags (long/strongly-typed style)
```cs
int intVal = myCompoundTag.Get("intTagsName");
string listItem = myStringList.Get(0);
byte nestedVal = myCompTag.Get("nestedTag")
.Get("someByteTag");
```
#### Accessing tags (shortcut style)
```cs
int intVal = myCompoundTag["intTagsName"];
string listItem = myStringList[0];
byte nestedVal = myCompTag["nestedTag"]["someByteTag"];
```
#### Iterating over all tags in a compound/list
```cs
foreach(NbtTag tag in myCompoundTag.Tags)
{
Console.WriteLine(tag.Name + " = " + tag.TagType);
}
foreach(string tagName in myCompoundTag.Tags.Keys)
{
Console.WriteLine(tagName);
}
for(int i = 0; i < myListTag.Count; i++)
{
Console.WriteLine(myListTag[i]);
}
foreach(NbtInt intItem in myIntList.ToArray())
{
Console.WriteLine(intItem);
}
```
#### Constructing a new document
```cs
var serverInfo = new NbtCompound("Server");
serverInfo.Add( new NbtString("Name", "BestServerEver") );
serverInfo.Add( new NbtInt("Players", 15) );
serverInfo.Add( new NbtInt("MaxPlayers", 20) );
```
#### Constructing using collection initializer notation
```cs
var nbt = new NbtDocument {
{ "someInt", 123 },
{ "byteList", {
new NbtByte(1),
new NbtByte(2),
new NbtByte(3)
} },
{
"nestedCompound",
{
{ "pi", (double)3.14 }
}
}
};
```
#### Pretty-printing
```cs
Console.WriteLine(myNbt.ToString());
```