MineSharp.fNbt 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package MineSharp.fNbt --version 1.0.2                
NuGet\Install-Package MineSharp.fNbt -Version 1.0.2                
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="MineSharp.fNbt" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MineSharp.fNbt --version 1.0.2                
#r "nuget: MineSharp.fNbt, 1.0.2"                
#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 MineSharp.fNbt as a Cake Addin
#addin nuget:?package=MineSharp.fNbt&version=1.0.2

// Install MineSharp.fNbt as a Cake Tool
#tool nuget:?package=MineSharp.fNbt&version=1.0.2                

Build status

This is a fork of https://github.com/mstefarov/fNbt, which allows anonymous NbtFiles (See wiki.vg)

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

Current released version is 0.6.4 (6 July 2018).

fNbt is based in part on Erik Davidson's (aphistic's) original LibNbt library, now completely rewritten by Matvei Stefarov (fragmer).

Note that fNbt.Test.dll and nunit.framework.dll do NOT need to be bundled with applications that use fNbt; they are only used for testing.

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 fNbt requires .NET Framework 3.5+ (client or full profile).

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
Check out unit tests in fNbt.Test for more examples.

API REFERENCE

Online reference can be found at http://www.fcraft.net/fnbt/v0.6.4/

LICENSING

fNbt v0.5.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).

VERSION HISTORY

See docs/Changelog.md

OLD VERSIONS

If you need .NET 2.0 support, stick to using fNbt version 0.5.1. Note that this 0.5.x branch of fNbt is no longer supported or updated.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net6.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MineSharp.fNbt:

Package Downloads
MineSharp.Core

Core types used by most MineSharp projects.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 1,540 1/13/2024
1.0.2 113 1/13/2024
1.0.1 269 1/7/2024
1.0.0 116 1/7/2024