SmartNbt 1.0.0

dotnet add package SmartNbt --version 1.0.0                
NuGet\Install-Package SmartNbt -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SmartNbt" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SmartNbt --version 1.0.0                
#r "nuget: SmartNbt, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SmartNbt as a Cake Addin
#addin nuget:?package=SmartNbt&version=1.0.0

// Install SmartNbt as a Cake Tool
#tool nuget:?package=SmartNbt&version=1.0.0                

SmartNbt

Named Binary Tag (NBT) is a structured binary file format used by Minecraft. SmartNbt is a small library, written in C# for .NET 6.0 (In progress of migrating). It provides functionality to create, load, traverse, modify, and save NBT files and streams.

Current released version is 1.0. Uses NET 6.0.

fNbt is based in part on Erik Davidson's (aphistic's) original LibNbt library, now completely rewritten by Matvei Stefarov (fragmer), then rewritten for Net 6.0 by CopperPenguin96 as SmartNbt.

FEATURES

  • Load and save uncompressed, GZip-, and ZLib-compressed files/streams.
  • Easily create, traverse, and modify NBT documents.
  • Simple indexer-based syntax for accessing compound, list, and nested tags.
  • Shortcut properties to access tags' values without unnecessary type casts.
  • Compound tags implement ICollection<T> and List tags implement IList<T>, for easy traversal and LINQ integration.
  • Good performance and low memory overhead.
  • Built-in pretty-printing of individual tags or whole files.
  • Every class and method are fully documented, annotated, and unit-tested.
  • Can work with both big-endian and little-endian NBT data and systems.
  • Optional high-performance reader/writer for working with streams directly.

DOWNLOAD

Latest version of SmartNbt requires .NET 6.0.

You can download from the releases tab or from Nuget.org

EXAMPLES

Loading a gzipped file
    var myFile = new NbtFile();
    myFile.LoadFromFile("somefile.nbt.gz");
    var myCompoundTag = myFile.RootTag;
Accessing tags (long/strongly-typed style)
    int intVal = myCompoundTag.Get<NbtInt>("intTagsName").Value;
    string listItem = myStringList.Get<NbtString>(0).Value;
    byte nestedVal = myCompTag.Get<NbtCompound>("nestedTag")
                              .Get<NbtByte>("someByteTag")
                              .Value;
Accessing tags (shortcut style)
    int intVal = myCompoundTag["intTagsName"].IntValue;
    string listItem = myStringList[0].StringValue;
    byte nestedVal = myCompTag["nestedTag"]["someByteTag"].ByteValue;
Iterating over all tags in a compound/list
    foreach( NbtTag tag in myCompoundTag.Values ){
        Console.WriteLine( tag.Name + " = " + tag.TagType );
    }
    foreach( string tagName in myCompoundTag.Names ){
        Console.WriteLine( tagName );
    }
    for( int i = 0; i < myListTag.Count; i++ ){
        Console.WriteLine( myListTag[i] );
    }
    foreach( NbtInt intItem in myIntList.ToArray<NbtInt>() ){
        Console.WriteLine( intItem.Value );
    }
Constructing a new document
    var serverInfo = new NbtCompound("Server");
    serverInfo.Add( new NbtString("Name", "BestServerEver") );
    serverInfo.Add( new NbtInt("Players", 15) );
    serverInfo.Add( new NbtInt("MaxPlayers", 20) );
    var serverFile = new NbtFile(serverInfo);
    serverFile.SaveToFile( "server.nbt", NbtCompression.None );
Constructing using collection initializer notation
    var compound = new NbtCompound("root"){
        new NbtInt("someInt", 123),
        new NbtList("byteList") {
            new NbtByte(1),
            new NbtByte(2),
            new NbtByte(3)
        },
        new NbtCompound("nestedCompound") {
            new NbtDouble("pi", 3.14)
        }
    };
Pretty-printing file structure
    Console.WriteLine( myFile.ToString("\t") ); // tabs
    Console.WriteLine( myRandomTag.ToString("    ") ); // spaces
Important Note

If this is a replacement for a previous version of this library (i.e. fNbt), please note that you will need to update your imports. fNbt should be changed to SmartNbt. Also, anywhere you have referenced an Exception from the library you will need to add the import "SmartNbt.Exceptions"

API REFERENCE

Online reference can be found at (Coming Soon)

LICENSING

SmartNbt 1.0 is licensed under 3-Clause BSD license; see docs/LICENSE. LibNbt2012 up to and including v0.4.1 kept LibNbt's original license (LGPLv3).

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 411 8/30/2021