Implement IntTag

This commit is contained in:
zontreck 2024-05-04 21:35:19 -07:00
parent 120328533c
commit 5642a7f693
2 changed files with 15 additions and 7 deletions

View file

@ -3,7 +3,7 @@ import 'package:libac_flutter/nbt/impl/CompoundTag.dart';
import 'package:libac_flutter/nbt/impl/DoubleTag.dart';
import 'package:libac_flutter/nbt/impl/EndTag.dart';
import 'package:libac_flutter/nbt/impl/FloatTag.dart';
import 'package:libac_flutter/nbt/impl/TagInt.dart';
import 'package:libac_flutter/nbt/impl/IntTag.dart';
import 'package:libac_flutter/nbt/impl/TagLong.dart';
import 'package:libac_flutter/nbt/impl/TagShort.dart';
@ -98,7 +98,7 @@ abstract class Tag {
case TagType.Short:
return new TagShort(value: 0);
case TagType.Int:
return new TagInt(value: 0);
return new IntTag();
case TagType.Long:
return new TagLong(value: 0);
case TagType.Float:

View file

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