![]() |
VOOZH | about |
dotnet add package fNbt --version 1.0.0
NuGet\Install-Package fNbt -Version 1.0.0
<PackageReference Include="fNbt" Version="1.0.0" />
<PackageVersion Include="fNbt" Version="1.0.0" />Directory.Packages.props
<PackageReference Include="fNbt" />Project file
paket add fNbt --version 1.0.0
#r "nuget: fNbt, 1.0.0"
#:package fNbt@1.0.0
#addin nuget:?package=fNbt&version=1.0.0Install as a Cake Addin
#tool nuget:?package=fNbt&version=1.0.0Install as a Cake Tool
Named Binary Tag (NBT) is a structured binary file format used by Minecraft. fNbt is a small library, written in C#. It provides functionality to create, load, traverse, modify, and save NBT files and streams. The library provides a choice of convenient high-level APIs (NbtFile/NbtTag) that present an object model, or lower-level higher-performance APIs (NbtReader/NbtWriter) that read/write data directly to/from streams.
Current released version is 1.0.0 (3 July 2025).
fNbt is based in part on Erik Davidson's (aphistic's) original LibNbt library, now completely rewritten by Matvei Stefarov (fragmer).
ICollection<T> and List tags implement IList<T>, for easy traversal and LINQ integration.Latest version of fNbt targets .NET Standard 2.0, which means it can be used in .NET Framework 4.6.1+, .NET Core 2.0+, Mono 5.4+, and more.
Package @ NuGet: https://www.nuget.org/packages/fNbt/
Compiled binaries and single-source-file amalgamations: https://github.com/mstefarov/fNbt/releases
var myFile = new NbtFile();
myFile.LoadFromFile("somefile.nbt.gz");
var myCompoundTag = myFile.RootTag;
int intVal = myCompoundTag.Get<NbtInt>("intTagsName").Value;
string listItem = myStringList.Get<NbtString>(0).Value;
byte nestedVal = myCompTag.Get<NbtCompound>("nestedTag")
.Get<NbtByte>("someByteTag")
.Value;
int intVal = myCompoundTag["intTagsName"].IntValue;
string listItem = myStringList[0].StringValue;
byte nestedVal = myCompTag["nestedTag"]["someByteTag"].ByteValue;
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 );
}
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 );
using (var fileStream = File.Create("foo.nbt", bufferSize: 4 * 1024)) {
var writer = new NbtWriter(fileStream, "Server");
writer.WriteString("Name", "BestServerEver");
writer.WriteInt("Players", 15);
writer.WriteInt("MaxPlayers", 20);
writer.EndCompound();
writer.Finish();
}
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)
}
};
Console.WriteLine( myFile.ToString("\t") ); // tabs
Console.WriteLine( myRandomTag.ToString(" ") ); // spaces
Online reference can be found at http://www.fcraft.net/fnbt/v1.0.0/
fNbt v0.5.0+ is licensed under 3-Clause BSD license; see . LibNbt2012 up to and including v0.4.1 kept LibNbt's original license (LGPLv3).
See
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on fNbt:
| Package | Downloads |
|---|---|
|
GemBlocks
A .NET standard library for easy saving/loading/generating of minecraft worlds. |
|
|
MCSharp
A minecraft network library to make it esier to create minecraft network apps like proxies, oder custom clients |
|
|
fNBT.Serialization
Serialization Part of fNBT |
|
|
MineJason.Serialization.fNbt
fNbt support for MineJason.Serialization |
|
|
NetherGate.API
Plugin API for NetherGate - A Minecraft server management platform. Provides interfaces and models for developing NetherGate plugins. |
Showing the top 3 popular GitHub repositories that depend on fNbt:
| Repository | Stars |
|---|---|
|
PCL-Community/PCL-CE
PCL 社区版 由社区开发者维护与管理
|
|
|
Zarbuz/FileToVox
Tool for convert files into Magicavoxel file
|
|
|
XianYuLauncher/XianYuLauncher
A UI-perfect Minecraft Java Edition launcher | XianYu Launcher
|
## 1.0.0 (fNbt)
- Library now targets .NET Standard 2.0 instead of .NET Framework, which
allows fNbt to be used in more types of projects (e.g. .NET 8 or UWP).
- Support TAG_Long_Array.
- Fix some edge-cases related to reading corrupted NBT files.
- Switch from JetBrains' annotations to .NET's built-in annotations.
## 0.6.4 (fNbt)
- Fixed a case where NbtBinaryReader.ReadString read too many bytes (#26).
- Fixed NbtList.Contains(null) throwing exception instead of returning false.
- Reduced NbtBinaryReader's maximum chunk size to 4 MB. This reduces peak
memory use when reading huge files without affecting performance.
## 0.6.3 (fNbt)
- Empty NbtLists now allow "TAG_End" as its ListType (#12).
## 0.6.2 (fNbt)
- NbtTags now implement ICloneable and provide copy constructors (#10).
- fNbt is now compatible with /checked compiler option.
- Fixed an OverflowException in .NET 4.0+ when writing arrays of size 1 GiB
(or larger) to a BufferedStream.
- Fixed a few edge cases in NbtReader when reading corrupt files.
- Minor optimizations and documentation fixes.
## 0.6.1 (fNbt)
- NbtReader now supports non-seekable streams.
- Fixed issues loading from/saving to non-seekable steams in NbtFile.
- NbtFile.LoadFromStream/SaveToStream now accurately report bytes read/written
for NBT data over 2 GiB in size.
- API change:
All NbtFile loading/saving methods now return long instead of int.
## 0.6.0 (fNbt)
- Raised .NET framework requirements from 2.0+ to 3.5+
- Added NbtWriter, for linearly writing NBT streams, similarly to XmlWriter.
It enables high-performance writing, without creating temp NbtTag objects.
- Fixed handling of lists-of-lists and lists-of-compound-tags in NbtReader.
- Fixed being able to add an NbtList to itself.
- API changes:
Removed NbtCompound.ToArray(), use NbtCompound.Tags.ToArray() instead.
Removed NbtCompound.ToNameArray(), use NbtCompound.Names.ToArray() instead.
- Improved tag reading and writing performance.
- Expanded unit test coverage.
## 0.5.1 (fNbt)
- Fixed ToString() methods of NbtReader and some NbtTags not respecting the
NbtTag.DefaultIndentString setting.
- Fixed being able to add a Compound tag to itself.
- Fixed NbtString value defaulting to null, instead of an empty string.
- Fixed a number of bugs in NbtReader.ReadListAsArray<T>().
- API additions:
New NbtReader property: bool IsAtStreamEnd
New NbtReader overload: string ToString(bool,string)
- Expanded unit test coverage.
## 0.5.0 (fNbt)
- Added NbtReader, for linearly reading NBT streams, similarly to XmlReader.
- API additions:
New NbtCompound method: bool TryGet(string,out NbtTag)
New NbtCompound overload: NbtTag Get(string)
New NbtTag property: bool HasValue
- License changed from LGPL to to 3-Clause BSD, since none of the original
libnbt source code remains.
## 0.4.1 (LibNbt2012)
- Added a way to set up default indent for NbtTag.ToString() methods, using
NbtTag.DefaultIndentString static property.
- Added a way to control/disable buffering when reading tags, using properties
NbtFile.DefaultBufferSize (static) and "nbtFile.BufferSize" (instance).
- Simplified renaming tags. Instead of using NbtFile.RenameRootTag or
NbtCompound.RenameTag, you can now set tag's Name property directly. It
will check parent tag automatically, and throw ArgumentException or
ArgumentNullException is renaming is not possible.
- NbtFile() constructor now initializes RootTag to an empty NbtCompound("").
- Added LoadFro* overloads that do not require a TagSelector parameter.
## 0.4.0 (LibNbt2012)
- Changed the way NbtFiles are constructed. Data is not loaded in the
constructor itself any more, use LoadFrom* method.
- Added a way to load NBT data directly from byte arrays, and to save them to
byte arrays.
- All LoadFrom-/SaveTo- methods now return an int, indicating the number of
bytes read/written.
- Updated NbtFile to override ToString.
- Added a way to control endianness when reading/writing NBT files.
## 0.3.4 (LibNbt2012)
- Added a way to rename tags inside NbtCompound and NbtFile.
## 0.3.3 (LibNbt2012)
- Added a way to skip certain tags at load-time, using a TagSelector callback.
## 0.3.2 (LibNbt2012)
- Added a way to easily identify files, using static NbtFile.ReadRootTagName.
- Added NbtTag.Parent (automatically set/reset by NbtList and NbtCompound).
- Added NbtTag.Path (which includes parents' names, and list indices).
- Added NbtCompound.Names and NbtCompound.Values enumerators.
## 0.3.1 (LibNbt2012)
- Added indexers to NbtTag base class, to make nested compound/list tags easier
to work with.
- Added shortcut properties for getting tag values.
- Added a ToArray<T>() overload to NbtList, to automate casting to a specific
tag type.
- Improved .ToString() pretty-printing, now with consistent and configurable
indentation.
## 0.3.0 (LibNbt2012)
- Auto-detection of NBT file compression.
- Loading and saving of ZLib (RFC-1950) compresessed NBT files.
- Reduced loading/saving CPU use by 15%, and memory use by 40%
- Full support for TAG_Int_Array
- NbtCompound now implements ICollection and ICollection<NbtTag>
- NbtList now implements IList and IList<NbtTag>
- More constraint checks to tag loading, modification, and saving.
- Replaced getter/setter methods with properties, wherever possible.
- Expanded unit test coverage.
- Fully documented everything.
- Made tag names immutable.
- Removed tag queries.
## 0.2.0 (libnbt)
- Implemented tag queries.
- Created unit tests for the larger portions of the code.
- Marked tag constructors that take only tag values as obsolete, use the
constructor that has name and value instead.
## 0.1.2 (libnbt)
- Added a GetTagType() function to the tag classes.
- Fixed saving NbtList tags.
## 0.1.1 (libnbt)
- Initial release.
- Modified the tag constructors to be consistant with each other.
- Changed NbtFile to allow some functions to be overridden.