Class NbtFile
Namespace: Void.Minecraft.Nbt
Assembly: Void.Minecraft.dll
Provides static convenience methods for working with NBT-formatted files, including both reading and writing.
public static class NbtFileInheritance
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Methods
OpenRead(string, FormatOptions, CompressionType)
Opens an existing NBT file for reading, and returns a
public static TagReader OpenRead(string path, FormatOptions options, CompressionType compression = CompressionType.AutoDetect)Parameters
path string
The path of the file to open for reading.
options FormatOptions
Bitwise flags to configure how data should be handled for compatibility between different specifications.
compression CompressionType
Indicates the compression algorithm used to compress the file.
Returns
A
Remarks
File compression will be automatically detected and handled when necessary.
OpenWrite(string, FormatOptions, CompressionType, CompressionLevel)
Opens an existing NBT file or creates a new one if it does not exist, and returns a
public static TagWriter OpenWrite(string path, FormatOptions options, CompressionType type = CompressionType.GZip, CompressionLevel level = CompressionLevel.Fastest)Parameters
path string
The path of the file to open for writing.
options FormatOptions
Bitwise flags to configure how data should be handled for compatibility between different specifications.
type CompressionType
A flag indicating the type of compression to use.
level CompressionLevel
A flag indicating the compression strategy that will be used, if any.
Returns
A
Read<T>(string, FormatOptions, CompressionType)
Reads a file at the given path and deserializes the top-level
public static T Read<T>(string path, FormatOptions options, CompressionType compression = CompressionType.AutoDetect) where T : Tag, ICollection<Tag>Parameters
path string
The path to the file to be read.
options FormatOptions
Bitwise flags to configure how data should be handled for compatibility between different specifications.
compression CompressionType
Indicates the compression algorithm used to compress the file.
Returns
T
The deserialized
Type Parameters
T
The type of tag to deserialize.
Read(string, FormatOptions, CompressionType)
Reads a file at the given path and deserializes the top-level
public static CompoundTag Read(string path, FormatOptions options, CompressionType compression = CompressionType.AutoDetect)Parameters
path string
The path to the file to be read.
options FormatOptions
Bitwise flags to configure how data should be handled for compatibility between different specifications.
compression CompressionType
Indicates the compression algorithm used to compress the file.
Returns
The deserialized
ReadAsync<T>(string, FormatOptions, CompressionType)
Asynchronously reads a file at the given path and deserializes the top-level
public static Task<T> ReadAsync<T>(string path, FormatOptions options, CompressionType compression = CompressionType.AutoDetect) where T : Tag, ICollection<Tag>Parameters
path string
The path to the file to be read.
options FormatOptions
Bitwise flags to configure how data should be handled for compatibility between different specifications.
compression CompressionType
Indicates the compression algorithm used to compress the file.
Returns
Task<T>
The deserialized
Type Parameters
T
ReadAsync(string, FormatOptions, CompressionType)
Asynchronously reads a file at the given path and deserializes the top-level
public static Task<CompoundTag> ReadAsync(string path, FormatOptions options, CompressionType compression = CompressionType.AutoDetect)Parameters
path string
The path to the file to be read.
options FormatOptions
Bitwise flags to configure how data should be handled for compatibility between different specifications.
compression CompressionType
Indicates the compression algorithm used to compress the file.
Returns
The deserialized
Write(string, CompoundTag, FormatOptions, CompressionType, CompressionLevel)
Writes the given tag to a file at the specified path.
public static void Write(string path, CompoundTag tag, FormatOptions options, CompressionType type = CompressionType.GZip, CompressionLevel level = CompressionLevel.Fastest)Parameters
path string
The path to the file to be written to.
tag CompoundTag
The top-level
options FormatOptions
Bitwise flags to configure how data should be handled for compatibility between different specifications.
type CompressionType
A flag indicating the type of compression to use.
level CompressionLevel
Indicates a compression strategy to be used, if any.
Write(string, ListTag, FormatOptions, CompressionType, CompressionLevel)
Writes the given tag to a file at the specified path.
public static void Write(string path, ListTag tag, FormatOptions options, CompressionType type = CompressionType.GZip, CompressionLevel level = CompressionLevel.Fastest)Parameters
path string
The path to the file to be written to.
tag ListTag
The top-level
options FormatOptions
Bitwise flags to configure how data should be handled for compatibility between different specifications.
type CompressionType
A flag indicating the type of compression to use.
level CompressionLevel
Indicates a compression strategy to be used, if any.
WriteAsync(string, CompoundTag, FormatOptions, CompressionType, CompressionLevel)
Asynchronously writes the given tag to a file at the specified path.
public static Task WriteAsync(string path, CompoundTag tag, FormatOptions options, CompressionType type = CompressionType.GZip, CompressionLevel level = CompressionLevel.Fastest)Parameters
path string
The path to the file to be written to.
tag CompoundTag
The top-level
options FormatOptions
Bitwise flags to configure how data should be handled for compatibility between different specifications.
type CompressionType
A flag indicating the type of compression to use.
level CompressionLevel
Indicates a compression strategy to be used, if any.
Returns
WriteAsync(string, ListTag, FormatOptions, CompressionType, CompressionLevel)
Asynchronously writes the given tag to a file at the specified path.
public static Task WriteAsync(string path, ListTag tag, FormatOptions options, CompressionType type = CompressionType.GZip, CompressionLevel level = CompressionLevel.Fastest)Parameters
path string
The path to the file to be written to.
tag ListTag
The top-level
options FormatOptions
Bitwise flags to configure how data should be handled for compatibility between different specifications.
type CompressionType
A flag indicating the type of compression to use.
level CompressionLevel
Indicates a compression strategy to be used, if any.