writeTag method

  1. @override
void writeTag(
  1. NbtWriter nbtWriter, {
  2. bool withName = true,
  3. bool withType = true,
})
override

Writes a NbtTag from fileReader. If the parent is a NbtList or NbtArray, withName should be set to false to avoid writing any names of this Tag.

Implementation

@override
void writeTag(NbtWriter nbtWriter,
    {bool withName = true, bool withType = true}) {
  if (withType) nbtWriter.writeByte(nbtTagType.index);
  if (withName) {
    nbtWriter.writeString(name);
  }
  for (final val in children) {
    val.writeTag(nbtWriter, withName: true, withType: true);
  }
  // Write the last NbtEnd tag as well, this one is not included in [children].
  NbtEnd(this).writeTag(nbtWriter);
}