readTag method

  1. @override
NbtByteArray readTag(
  1. NbtReader nbtReader, {
  2. bool withName = true,
})
override

Reads a NbtTag from fileReader. If the parent is a NbtList or NbtArray, withName should be set to false to avoid reading the name of this Tag.

Implementation

@override
NbtByteArray readTag(NbtReader nbtReader, {bool withName = true}) {
  final name = withName
      ? nbtReader.readString()
      : 'None'; // On the root node, this should be a empty string
  final length = nbtReader.readInt(signed: true);
  for (var i = 0; i < length; i++) {
    add(nbtReader.readByte(signed: true));
  }
  return this..name = name;
}