Implement ShortTag
This commit is contained in:
parent
b4b2370e34
commit
3956dc0ea9
2 changed files with 15 additions and 7 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
Loading…
Reference in a new issue