Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/c272/nbt.net
A serialization library for the NBT file format, created by Notch.
https://github.com/c272/nbt.net
csharp minecraft named-binary-tag nbt nbt-parser
Last synced: 30 days ago
JSON representation
A serialization library for the NBT file format, created by Notch.
- Host: GitHub
- URL: https://github.com/c272/nbt.net
- Owner: c272
- Created: 2020-07-19T18:58:01.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-02-01T16:41:28.000Z (almost 3 years ago)
- Last Synced: 2023-03-06T08:06:56.497Z (almost 2 years ago)
- Topics: csharp, minecraft, named-binary-tag, nbt, nbt-parser
- Language: C#
- Homepage:
- Size: 78.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![NBT.NET](logo.png)
*A serialization library for the NBT file format created by Notch.*
![](https://img.shields.io/travis/com/c272/nbt.net)
![](https://img.shields.io/github/issues/c272/nbt.net)
![](https://img.shields.io/github/license/c272/nbt.net)# Overview
NBT.NET is a serialization library designed to work with Notch's "Named Binary Tag" format, created for Minecraft. It includes functions to deserialize NBT data into standard C# classes, as well as vice versa. The entire project is written on .NET Core 3.1 and can be retargeted to .NET Standard.# Usage
To deserialize a file into a specified C# class, you would first create classes with `NBTItem` and `NBTCompound` attributes, like so:
```cs
using NBT;
...[NBTCompound]
public class ExampleNBT
{
[NBTItem]
public int SomeInteger { get; set; }
[NBTItem("nbtPropertyName")] //this sets the name to match from the nbt as "nbtPropertyName" rather than the C# property name
public string SomeString { get; set; }
[NBTItem("^[A-Za-z0-9]+_thing$", true)] //this sets the deserializer to match properties with the given regex
public long[] RegexedProperty { get; set; }
}
```After you define classes to hold the NBT data, you can deserialize like so:
```cs
byte[] nbtData = File.ReadAllBytes("level.dat");
ExampleNBT deserialized = NBT.Deserialize(nbtData);
```