NbtIo
Namespace Mc.Scripting.Nbt · Kind class (static)
public static class NbtIoBinary NBT (the file form of the game: type byte, name, payload; big endian; strings in Java’s modified UTF-8). Reading enforces a nesting depth of 512 like the game.
Fields
Section titled “Fields”| Member | Description |
|---|---|
const long DefaultQuota = 33554432 |
How much memory (in the accounting of the game’s NbtAccounter: about 48 bytes per tag, plus strings and arrays) a read may build: 32 MiB. |
DefaultQuota
Section titled “DefaultQuota”public const long DefaultQuota = 33554432;How much memory (in the accounting of the game’s NbtAccounter: about 48 bytes per tag, plus strings and arrays) a read may build: 32 MiB. A few bytes of input can describe a very large tree (a list of a million empty compounds is one megabyte of data and a hundred megabytes of objects); the quota stops it.
Methods
Section titled “Methods”| Member | Description |
|---|---|
static NbtTag Read(ReadOnlySpan<byte> data) |
Parses a named root tag (the name is ignored). |
static NbtTag Read(ReadOnlySpan<byte> data, long quota) |
Parses a named root tag with an explicit memory quota. |
static byte[] Write(NbtTag tag) |
Serialises a tag as a named root with an empty name. |
public static NbtTag Read(ReadOnlySpan<byte> data)Parses a named root tag (the name is ignored).
Parameters
| Name | Type | Description |
|---|---|---|
data |
ReadOnlySpan<byte> |
The bytes (not compressed). |
Returns NbtTag: The tag.
Throws
System.FormatException: The data is truncated or malformed.
public static NbtTag Read(ReadOnlySpan<byte> data, long quota)Parses a named root tag with an explicit memory quota.
Parameters
| Name | Type | Description |
|---|---|---|
data |
ReadOnlySpan<byte> |
The bytes (not compressed). |
quota |
long |
The most accounted memory the tree may take (see NbtIo.DefaultQuota). |
Returns NbtTag: The tag.
Throws
System.FormatException: The data is truncated, malformed, nested too deeply or larger than the quota.
public static byte[] Write(NbtTag tag)Serialises a tag as a named root with an empty name.
Parameters
| Name | Type | Description |
|---|---|---|
tag |
NbtTag |
The tag. |
Returns byte[]: The bytes.