Class NBTIO

java.lang.Object
com.viaversion.nbt.io.NBTIO

public final class NBTIO extends Object
Utility to read and write NBT tags.
  • Method Details

    • reader

      public static TagReader<Tag> 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

      public static <T extends Tag> TagReader<T> reader(Class<T> expectedTagType)
      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

      public static TagWriter 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 from
      tagLimiter - tag limiter to use
      named - whether the tag is named
      expectedTagType - the expected tag type, or null if any is accepted
      Returns:
      the read tag
      Throws:
      IOException - if an I/O error occurs
    • writeTag

      public static void writeTag(DataOutput out, Tag tag, boolean named) throws IOException
      Writes a named NBT tag to a data output.
      Parameters:
      out - output stream to write to
      tag - tag to write
      Throws:
      IOException - if an I/O error occurs