Implement ShortTag

This commit is contained in:
zontreck 2024-05-04 22:55:23 -07:00
parent b4b2370e34
commit 3956dc0ea9
2 changed files with 15 additions and 7 deletions

View file

@ -6,7 +6,7 @@ import 'package:libac_flutter/nbt/impl/FloatTag.dart';
import 'package:libac_flutter/nbt/impl/IntArrayTag.dart';
import 'package:libac_flutter/nbt/impl/IntTag.dart';
import 'package:libac_flutter/nbt/impl/LongTag.dart';
import 'package:libac_flutter/nbt/impl/TagShort.dart';
import 'package:libac_flutter/nbt/impl/ShortTag.dart';
import 'Stream.dart';
import 'impl/ByteTag.dart';
@ -113,7 +113,7 @@ abstract class Tag {
case TagType.End:
return new EndTag();
case TagType.Short:
return new TagShort(value: 0);
return new ShortTag();
case TagType.Int:
return new IntTag();
case TagType.Long:

View file

@ -1,18 +1,26 @@
import 'package:libac_flutter/nbt/Stream.dart';
import 'package:libac_flutter/nbt/Tag.dart';
class TagShort extends Tag {
final int value;
TagShort({required this.value});
class ShortTag extends Tag {
int _value = 0;
ShortTag();
ShortTag._(int value) {
_value = value;
}
static ShortTag valueOf(int value) {
return ShortTag._(value);
}
@override
void readValue(ByteLayer data) {
// TODO: implement readValue
_value = data.readShort();
}
@override
void writeValue(ByteLayer data) {
// TODO: implement writeValue
data.writeShort(_value);
}
@override