Finish serialization in ByteArrayTag.dart

This commit is contained in:
zontreck 2024-05-04 20:39:00 -07:00
parent a8d99586c9
commit a27248daf9
2 changed files with 30 additions and 22 deletions

View file

@ -0,0 +1,30 @@
import 'package:libac_flutter/nbt/Stream.dart';
import 'package:libac_flutter/nbt/Tag.dart';
class ByteArrayTag extends Tag {
List<int> _value = [];
ByteArrayTag(List<int> value) {
_value.addAll(value);
}
@override
void readValue(ByteLayer data) {
int len = data.readInt();
for (int i = 0; i < len; i++) {
_value.add(data.readByte());
}
}
@override
void writeValue(ByteLayer data) {
data.writeInt(_value.length);
for (int i in _value) {
data.writeByte(i);
}
}
@override
TagType getTagType() {
return TagType.ByteArray;
}
}

View file

@ -1,22 +0,0 @@
import 'package:libac_flutter/nbt/Stream.dart';
import 'package:libac_flutter/nbt/Tag.dart';
class TagByteArray extends Tag {
final List<int> value;
TagByteArray({required this.value});
@override
void readValue(ByteLayer data) {
// TODO: implement readValue
}
@override
void writeValue(ByteLayer data) {
// TODO: implement writeValue
}
@override
TagType getTagType() {
return TagType.ByteArray;
}
}