java.lang.Object
at.syntaxerror.syntaxnbt.NBTUtil
A utility class for serializing and deserializing NBT and SNBT
- Author:
- SyntaxError404
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intThe default maximum number of layers to traverse whenserializing/stringifying -
Method Summary
Modifier and TypeMethodDescriptionstatic TagCompounddeserialize(InputStream input) Reads and populates a compound tag from a stream (NBT format).static TagCompounddeserialize(InputStream input, NBTCompression compression) Reads and populates a compound tag from a stream (NBT format)static RegionReads and populates a region from a filestatic TagCompoundReads and populates a compound tag from a string (SNBT format)static PathNodeReads an NBT path from a stringstatic voidserialize(String name, TagCompound compound, OutputStream output) Writes a compound tag to a stream (NBT format)static voidserialize(String name, TagCompound compound, OutputStream output, NBTCompression compression) Writes a compound tag to a stream (NBT format)static voidserializeRegion(Region region, RandomAccessFile output) Writes a region to a filestatic StringWrites an NBT path to a stringstatic Stringstringify(TagCompound compound) Writes a compound tag to a string (SNBT format)static Stringstringify(TagCompound compound, boolean colored) Writes a compound tag to a string (SNBT format).
-
Field Details
-
MAX_DEPTH
public static int MAX_DEPTHThe default maximum number of layers to traverse whenserializing/stringifying
-
-
Method Details
-
deserialize
Reads and populates a compound tag from a stream (NBT format). If the stream iscompressed, it is decompressed automatically- Parameters:
input- stream to read from- Returns:
- the deserialized tag
- Throws:
IOException- if an I/O error occured- See Also:
-
deserialize
public static TagCompound deserialize(InputStream input, NBTCompression compression) throws IOException Reads and populates a compound tag from a stream (NBT format)- Parameters:
input- stream to read fromcompression- compression of the stream- Returns:
- the deserialized tag
- Throws:
IOException- if an I/O error occured- See Also:
-
deserializeRegion
Reads and populates a region from a file- Parameters:
input- file to read from- Returns:
- the deserialized region
- Throws:
IOException- if an I/O error occured
-
serialize
public static void serialize(String name, TagCompound compound, OutputStream output) throws IOException Writes a compound tag to a stream (NBT format)- Parameters:
name- name of the compound tag (optional)compound- compound tag to be serializedoutput- stream to write to- Throws:
IOException- if an I/O error occured- See Also:
-
serialize
public static void serialize(String name, TagCompound compound, OutputStream output, NBTCompression compression) throws IOException Writes a compound tag to a stream (NBT format)- Parameters:
name- name of the compound tag (optional)compound- compound tag to be serializedoutput- stream to write tocompression- compression scheme to apply to the stream- Throws:
IOException- if an I/O error occured- See Also:
-
serializeRegion
Writes a region to a file- Parameters:
region- region to be serializedoutput- file to write to- Throws:
IOException- if an I/O error occured
-
parse
Reads and populates a compound tag from a string (SNBT format)- Parameters:
input- string to read from- Returns:
- the parsed tag
-
parsePath
Reads an NBT path from a string- Parameters:
input- string to read from- Returns:
- the parsed path
-
stringify
Writes a compound tag to a string (SNBT format)- Parameters:
compound- compound tag to be stringifyed- Returns:
- the stringifyed compound tag
-
stringify
Writes a compound tag to a string (SNBT format). Ifcolored, the string will contain color codes (according to Minecraft's old chat color system using section signsยง)- Parameters:
compound- compound tag to be stringifyedcolored- whether the string should contain color codes- Returns:
- the stringifyed compound tag
-
stringify
Writes an NBT path to a string- Parameters:
path- path node to be stringifyed- Returns:
- the stringifyed path
-