Package com.viaversion.nbt.io
Class NBTIO
java.lang.Object
com.viaversion.nbt.io.NBTIO
Utility to read and write NBT tags.
-
Method Summary
Modifier and TypeMethodDescriptionreader()Returns an NBT tag reader.Returns an NBT tag reader to read an expected tag type.static <T extends Tag>
TreadTag(DataInput in, TagLimiter tagLimiter, boolean named, @Nullable Class<T> expectedTagType) Reads a named NBT tag from a data input.static TagWriterwriter()Returns a reusable NBT tag writer.static voidwriteTag(DataOutput out, Tag tag, boolean named) Writes a named NBT tag to a data output.
-
Method Details
-
reader
Returns an NBT tag reader. If a tag limiter is set, the reader is reusable, but not thread-safe.- Returns:
- NBT tag reader
-
reader
Returns an NBT tag reader to read an expected tag type. If a tag limiter is set, the reader is reusable, but not thread-safe.- Type Parameters:
T- the expected tag type- Parameters:
expectedTagType- the expected tag type, or null if any is accepted- Returns:
- NBT tag reader
-
writer
Returns a reusable NBT tag writer.- Returns:
- reusable NBT tag writer
-
readTag
public static <T extends Tag> T readTag(DataInput in, TagLimiter tagLimiter, boolean named, @Nullable @Nullable Class<T> expectedTagType) throws IOException Reads a named NBT tag from a data input.- Parameters:
in- input stream to read fromtagLimiter- tag limiter to usenamed- whether the tag is namedexpectedTagType- the expected tag type, or null if any is accepted- Returns:
- the read tag
- Throws:
IOException- if an I/O error occurs
-
writeTag
Writes a named NBT tag to a data output.- Parameters:
out- output stream to write totag- tag to write- Throws:
IOException- if an I/O error occurs
-