Adds a new functions to the NBT Tag abstract: getter and setter for value

This commit is contained in:
zontreck 2024-07-21 05:19:57 -07:00
parent ba8315f5ee
commit fdb5669897
15 changed files with 113 additions and 1 deletions

View file

@ -173,6 +173,10 @@ abstract class Tag {
_key = key;
}
dynamic getValue();
void setValue(dynamic val);
static Tag readNamedTag(ByteLayer data) {
var type = data.readByte();
if (type == 0) {

View file

@ -35,6 +35,12 @@ class ByteArrayTag extends Tag {
return TagType.ByteArray;
}
@override
dynamic getValue() {}
@override
void setValue(dynamic val) {}
@override
void prettyPrint(int indent, bool recurse) {
String array = "";

View file

@ -29,6 +29,16 @@ class ByteTag extends Tag {
return TagType.Byte;
}
@override
getValue() {
return value;
}
@override
void setValue(val) {
if (val is int) this.value = value;
}
@override
void prettyPrint(int indent, bool recurse) {
print(

View file

@ -64,6 +64,14 @@ class CompoundTag extends Tag implements Map<String, Tag> {
return TagType.Compound;
}
@override
getValue() {
return null;
}
@override
void setValue(val) {}
@override
void prettyPrint(int indent, bool recurse) {
print(

View file

@ -29,6 +29,16 @@ class DoubleTag extends Tag {
return TagType.Double;
}
@override
void setValue(val) {
if (val is double) value = val;
}
@override
getValue() {
return value;
}
@override
void prettyPrint(int indent, bool recurse) {
print(

View file

@ -15,6 +15,12 @@ class EndTag extends Tag {
return TagType.End;
}
@override
void setValue(val) {}
@override
getValue() {}
@override
void prettyPrint(int indent, bool recurse) {
print("${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}");

View file

@ -28,6 +28,16 @@ class FloatTag extends Tag {
return TagType.Float;
}
@override
getValue() {
return value;
}
@override
void setValue(val) {
value = val;
}
@override
void prettyPrint(int indent, bool recurse) {
print(

View file

@ -34,6 +34,12 @@ class IntArrayTag extends Tag {
return TagType.IntArray;
}
@override
void setValue(val) {}
@override
getValue() {}
@override
void prettyPrint(int indent, bool recurse) {
String array = "";

View file

@ -28,6 +28,16 @@ class IntTag extends Tag {
return TagType.Int;
}
@override
void setValue(val) {
if (val is int) value = val;
}
@override
getValue() {
return value;
}
@override
void prettyPrint(int indent, bool recurse) {
print(

View file

@ -69,6 +69,12 @@ class ListTag extends Tag {
return TagType.List;
}
@override
void setValue(val) {}
@override
getValue() {}
int size() {
return value.length;
}

View file

@ -38,6 +38,12 @@ class LongArrayTag extends Tag {
return TagType.LongArray;
}
@override
void setValue(val) {}
@override
getValue() {}
@override
void prettyPrint(int indent, bool recurse) {
String array = "";

View file

@ -28,6 +28,16 @@ class LongTag extends Tag {
return TagType.Long;
}
@override
void setValue(val) {
if (val is int) value = val;
}
@override
getValue() {
return value;
}
@override
void prettyPrint(int indent, bool recurse) {
print(

View file

@ -28,6 +28,16 @@ class ShortTag extends Tag {
return TagType.Short;
}
@override
void setValue(val) {
if (val is int) value = val;
}
@override
getValue() {
return value;
}
@override
void prettyPrint(int indent, bool recurse) {
print(

View file

@ -28,6 +28,16 @@ class StringTag extends Tag {
return TagType.String;
}
@override
void setValue(val) {
if (val is String) value = val;
}
@override
getValue() {
return value;
}
@override
void prettyPrint(int indent, bool recurse) {
print(

View file

@ -1,6 +1,6 @@
name: libac_dart
description: "Aria's Creations code library"
version: 1.2.072024+2043
version: 1.2.072124+0507
homepage: "https://zontreck.com"