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);
  }
  nbtWriter.writeByte(childrenTagType.index);
  nbtWriter.writeInt(children.length, signed: true);
  for (final val in children) {
    val.writeTag(nbtWriter, withName: false, withType: false);
  }
}