write method

List<int> write(
  1. NbtCompound<NbtTag> data
)

Write the given data compound into a list of bytes. See writeFile on how to quickly write to a file. Remember that on Bedrock, all NBT files will have to be written with Endian.little.

Implementation

List<int> write(NbtCompound data) {
  _root ??= data;

  _root?.writeTag(this, withName: true, withType: true);

  flush(ByteWriter.megaByte);

  final builtBytes = bytesBuilder.toBytes();
  return nbtCompression.compressData(builtBytes);
}