GithubHelp home page GithubHelp logo

daanv2 / daanv2.nbt.net Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 2.4 MB

A NBT library for reading and writing nbt files/data, with support for little or big endian

Home Page: https://www.nuget.org/packages/DaanV2.NBT.Net/

License: ISC License

C# 99.94% Makefile 0.06%
isc nbt nbt-library nbt-api nbt-protocol csharp csharp-library dotnet little-endian big-endian

daanv2.nbt.net's Introduction

DaanV2-NBT.Net

.NET Unit test ๐Ÿ“ฆ Nuget Release
Nuget Version Nuget Downloads

An NBT library for reading and writing NBT files/data Nuget package

Usage

Read a file

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<Int32>();

//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<Int32>("Age");

Writes to a file

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

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

daanv2.nbt.net's People

Contributors

actions-user avatar daanv2 avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

daanv2.nbt.net's Issues

Incomplete Documentation

I was trying to use this library but apparently it lacks sufficient documentation. For example, the NBTReader returns an ITag but how do I go about getting the tags I wrote to the file?

I wrote with this based on what I found:

CompoundBuilder bldNBT = new CompoundBuilder(ROOT);
                bldNBT.Add(ROOT_APP, "title");
                bldNBT.Add(ROOT_MOD, "module");
                bldNBT.Add(ROOT_VER, "1.0.0.0");
                bldNBT.Add(ROOT_USR, System.Security.Principal.WindowsIdentity.GetCurrent().Name);
                bldNBT.Add(ROOT_AUT, 1);
                bldNBT.Add(ROOT_DTC, ticks);
                bldNBT.Add(ROOT_DTM, ticks);
                ITag tag = bldNBT.GetResult();
                NBTWriter.WriteFile(fsScanAuto, tag, NBTCompression.Auto, DaanV2.Binary.Endianness.LittleEndian);

that I hope is correct. But then I am stumped at this part:

ITag obj = NBTReader.ReadFile("filename", Endianness.LitleEndian);

there is no documentation explaining how I retrieve the values I wrote and there is no Intellisense or anything that could shed some light into this stuff. How about updating a Tag value on ITag

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.