Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/daanv2/daanv2.nbt.net
A NBT library for reading and writing nbt files/data, with support for little or big endian
https://github.com/daanv2/daanv2.nbt.net
big-endian csharp csharp-library dotnet isc little-endian minecraft nbt nbt-api nbt-library nbt-protocol nuget
Last synced: 27 days ago
JSON representation
A NBT library for reading and writing nbt files/data, with support for little or big endian
- Host: GitHub
- URL: https://github.com/daanv2/daanv2.nbt.net
- Owner: DaanV2
- License: isc
- Created: 2019-06-28T21:04:01.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-05-01T13:22:33.000Z (9 months ago)
- Last Synced: 2024-05-02T08:28:38.671Z (9 months ago)
- Topics: big-endian, csharp, csharp-library, dotnet, isc, little-endian, minecraft, nbt, nbt-api, nbt-library, nbt-protocol, nuget
- Language: C#
- Homepage: https://www.nuget.org/packages/DaanV2.NBT.Net/
- Size: 2.34 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# DaanV2-NBT.Net
[![.NET Unit test](https://github.com/DaanV2/DaanV2.NBT.Net/actions/workflows/dotnet-test.yml/badge.svg)](https://github.com/DaanV2/DaanV2.NBT.Net/actions/workflows/dotnet-test.yml)
[![📦 Nuget Release](https://github.com/DaanV2/DaanV2.NBT.Net/actions/workflows/publish.yml/badge.svg)](https://github.com/DaanV2/DaanV2.NBT.Net/actions/workflows/publish.yml)
![Nuget Version](https://img.shields.io/nuget/v/DaanV2.NBT.Net)
![Nuget Downloads](https://img.shields.io/nuget/dt/DaanV2.NBT.Net)An NBT library for reading and writing NBT files/data [Nuget package](https://www.nuget.org/packages/DaanV2.NBT.Net/)
# Usage
## Read a file
```cs
var Compound = NBTReader.ReadFile("Path to file", Endian.Little, NBTCompression.Auto);
var age = Compound.GetChild("Age");//Retrieve value if you know what type it should be
Int32 item = age.GetValue();//OR
if (age is NBTTagInt a) {
Assert.IsTrue(a.Value == 256, "Hello set wrong")
}//OR
if (age.TryGetValue(out Int32 item)) {
Assert.IsTrue(item == 256, "Hello set wrong")
}//OR
var item = Compound.GetChild("Age");
```## Writes to a file
```cs
ITag Tag;//Writes the tag to the specified file using GZIP compression and little-endian methods
NBTWriter.WriteFile("Path to file", Tag, NBTCompression.Gzip, Endian.Little);//Writes the tag to the specified file using no compression and little-endian methods
NBTWriter.WriteFile("Path to file", Tag, Endian.Little);
```## Building a structure
```cs
CompoundBuilder Builder = new CompoundBuilder("Root", 10);
Builder.Add("IsDetermined", true);
Builder.Add("Amount", 5);ITag = Builder.GetResult();
```# Installation
Check that the NuGet packages have been downloaded.
# Dependencies:
## Solved with NuGet
- [Zlib](https://github.com/cinderblocks/zlib.net)
- [DaanV2.Essentials.Net](https://github.com/DaanV2/DaanV2.Essentials.Net)