Apply autofixes

This commit is contained in:
zontreck 2024-05-06 13:45:52 -07:00
parent 5357da3746
commit dd6ee1bf60
15 changed files with 36 additions and 30 deletions

View file

@ -15,8 +15,9 @@ class NbtUtils {
static bool readBoolean(CompoundTag tag, String name) { static bool readBoolean(CompoundTag tag, String name) {
if (tag.contains(name)) { if (tag.contains(name)) {
return tag.get(name)!.asByte() == 1 ? true : false; return tag.get(name)!.asByte() == 1 ? true : false;
} else } else {
return false; return false;
}
} }
static void writeVector2d(CompoundTag tag, String name, Vector2d pos) { static void writeVector2d(CompoundTag tag, String name, Vector2d pos) {
@ -30,8 +31,9 @@ class NbtUtils {
if (tag.contains(name)) { if (tag.contains(name)) {
ListTag lst = tag.get(name)! as ListTag; ListTag lst = tag.get(name)! as ListTag;
return Vector2d(X: lst.get(0).asDouble(), Z: lst.get(1).asDouble()); return Vector2d(X: lst.get(0).asDouble(), Z: lst.get(1).asDouble());
} else } else {
return Vector2d.ZERO; return Vector2d.ZERO;
}
} }
static void writeVector2i(CompoundTag tag, String name, Vector2i pos) { static void writeVector2i(CompoundTag tag, String name, Vector2i pos) {
@ -45,8 +47,9 @@ class NbtUtils {
if (tag.contains(name)) { if (tag.contains(name)) {
ListTag lst = tag.get(name)! as ListTag; ListTag lst = tag.get(name)! as ListTag;
return Vector2i(X: lst.get(0).asInt(), Z: lst.get(1).asInt()); return Vector2i(X: lst.get(0).asInt(), Z: lst.get(1).asInt());
} else } else {
return Vector2i.ZERO; return Vector2i.ZERO;
}
} }
static void writeVector3d(CompoundTag tag, String name, Vector3d pos) { static void writeVector3d(CompoundTag tag, String name, Vector3d pos) {
@ -64,8 +67,9 @@ class NbtUtils {
X: lst.get(0).asDouble(), X: lst.get(0).asDouble(),
Y: lst.get(1).asDouble(), Y: lst.get(1).asDouble(),
Z: lst.get(2).asDouble()); Z: lst.get(2).asDouble());
} else } else {
return Vector3d.ZERO; return Vector3d.ZERO;
}
} }
static void writeVector3i(CompoundTag tag, String name, Vector3i pos) { static void writeVector3i(CompoundTag tag, String name, Vector3i pos) {
@ -81,7 +85,8 @@ class NbtUtils {
ListTag lst = tag.get(name)! as ListTag; ListTag lst = tag.get(name)! as ListTag;
return Vector3i( return Vector3i(
X: lst.get(0).asInt(), Y: lst.get(1).asInt(), Z: lst.get(2).asInt()); X: lst.get(0).asInt(), Y: lst.get(1).asInt(), Z: lst.get(2).asInt());
} else } else {
return Vector3i.ZERO; return Vector3i.ZERO;
}
} }
} }

View file

@ -279,10 +279,10 @@ class NBTAccountant {
static void leaveTag(Tag tag) { static void leaveTag(Tag tag) {
if (tag is CompoundTag || tag is ListTag) { if (tag is CompoundTag || tag is ListTag) {
if (tag is CompoundTag) { if (tag is CompoundTag) {
CompoundTag ct = tag as CompoundTag; CompoundTag ct = tag;
ct.endPrettyPrint(_prettyIndex); ct.endPrettyPrint(_prettyIndex);
} else if (tag is ListTag) { } else if (tag is ListTag) {
ListTag lt = tag as ListTag; ListTag lt = tag;
lt.endPrettyPrint(_prettyIndex); lt.endPrettyPrint(_prettyIndex);
} }
} }

View file

@ -39,11 +39,11 @@ class ByteArrayTag extends Tag {
void prettyPrint(int indent, bool recurse) { void prettyPrint(int indent, bool recurse) {
String array = ""; String array = "";
for (int b in value) { for (int b in value) {
array += "${b}, "; array += "$b, ";
} }
array = array.substring(0, array.length - 2); array = array.substring(0, array.length - 2);
print( print(
"${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: [${array}]"); "${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: [$array]");
} }
} }

View file

@ -32,6 +32,6 @@ class ByteTag extends Tag {
@override @override
void prettyPrint(int indent, bool recurse) { void prettyPrint(int indent, bool recurse) {
print( print(
"${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: ${value}"); "${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: $value");
} }
} }

View file

@ -32,6 +32,6 @@ class DoubleTag extends Tag {
@override @override
void prettyPrint(int indent, bool recurse) { void prettyPrint(int indent, bool recurse) {
print( print(
"${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: ${value}"); "${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: $value");
} }
} }

View file

@ -31,6 +31,6 @@ class FloatTag extends Tag {
@override @override
void prettyPrint(int indent, bool recurse) { void prettyPrint(int indent, bool recurse) {
print( print(
"${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: ${value}"); "${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: $value");
} }
} }

View file

@ -34,11 +34,11 @@ class IntArrayTag extends Tag {
void prettyPrint(int indent, bool recurse) { void prettyPrint(int indent, bool recurse) {
String array = ""; String array = "";
for (int b in value) { for (int b in value) {
array += "${b}, "; array += "$b, ";
} }
array = array.substring(0, array.length - 2); array = array.substring(0, array.length - 2);
print( print(
"${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: [${array}]"); "${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: [$array]");
} }
} }

View file

@ -31,6 +31,6 @@ class IntTag extends Tag {
@override @override
void prettyPrint(int indent, bool recurse) { void prettyPrint(int indent, bool recurse) {
print( print(
"${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: ${value}"); "${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: $value");
} }
} }

View file

@ -45,10 +45,11 @@ class ListTag extends Tag {
} }
Tag get(int index) { Tag get(int index) {
if (size() > index) if (size() > index) {
return value[index]; return value[index];
else } else {
return EndTag(); return EndTag();
}
} }
void remove(Tag tag) { void remove(Tag tag) {

View file

@ -42,11 +42,11 @@ class LongArrayTag extends Tag {
void prettyPrint(int indent, bool recurse) { void prettyPrint(int indent, bool recurse) {
String array = ""; String array = "";
for (int b in value) { for (int b in value) {
array += "${b}, "; array += "$b, ";
} }
array = array.substring(0, array.length - 2); array = array.substring(0, array.length - 2);
print( print(
"${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: [${array}]"); "${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: [$array]");
} }
} }

View file

@ -31,6 +31,6 @@ class LongTag extends Tag {
@override @override
void prettyPrint(int indent, bool recurse) { void prettyPrint(int indent, bool recurse) {
print( print(
"${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: ${value}"); "${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: $value");
} }
} }

View file

@ -31,6 +31,6 @@ class ShortTag extends Tag {
@override @override
void prettyPrint(int indent, bool recurse) { void prettyPrint(int indent, bool recurse) {
print( print(
"${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: ${value}"); "${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: $value");
} }
} }

View file

@ -31,6 +31,6 @@ class StringTag extends Tag {
@override @override
void prettyPrint(int indent, bool recurse) { void prettyPrint(int indent, bool recurse) {
print( print(
"${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: ${value}"); "${"".padLeft(indent, '\t')}${Tag.getCanonicalName(getTagType())}: $value");
} }
} }

View file

@ -8,7 +8,7 @@ class Vector2d {
@override @override
bool operator ==(Object otherz) { bool operator ==(Object otherz) {
if (otherz is Vector2d) { if (otherz is Vector2d) {
Vector2d other = otherz as Vector2d; Vector2d other = otherz;
return X == other.X && Z == other.Z; return X == other.X && Z == other.Z;
} }
return false; return false;
@ -60,7 +60,7 @@ class Vector2d {
@override @override
String toString() { String toString() {
return "<${X}, ${Z}>"; return "<$X, $Z>";
} }
bool inside(Vector2d min, Vector2d max) { bool inside(Vector2d min, Vector2d max) {
@ -84,7 +84,7 @@ class Vector2i {
@override @override
bool operator ==(Object otherz) { bool operator ==(Object otherz) {
if (otherz is Vector2i) { if (otherz is Vector2i) {
Vector2i other = otherz as Vector2i; Vector2i other = otherz;
return X == other.X && Z == other.Z; return X == other.X && Z == other.Z;
} }
return false; return false;
@ -136,7 +136,7 @@ class Vector2i {
@override @override
String toString() { String toString() {
return "<${X}, ${Z}>"; return "<$X, $Z>";
} }
bool inside(Vector2i min, Vector2i max) { bool inside(Vector2i min, Vector2i max) {

View file

@ -9,7 +9,7 @@ class Vector3d {
@override @override
bool operator ==(Object otherz) { bool operator ==(Object otherz) {
if (otherz is Vector3d) { if (otherz is Vector3d) {
Vector3d other = otherz as Vector3d; Vector3d other = otherz;
return X == other.X && Y == other.Y && Z == other.Z; return X == other.X && Y == other.Y && Z == other.Z;
} }
return false; return false;
@ -65,7 +65,7 @@ class Vector3d {
@override @override
String toString() { String toString() {
return "<${X}, ${Y}, ${Z}>"; return "<$X, $Y, $Z>";
} }
bool inside(Vector3d min, Vector3d max) { bool inside(Vector3d min, Vector3d max) {
@ -92,7 +92,7 @@ class Vector3i {
@override @override
bool operator ==(Object otherz) { bool operator ==(Object otherz) {
if (otherz is Vector3i) { if (otherz is Vector3i) {
Vector3i other = otherz as Vector3i; Vector3i other = otherz;
return X == other.X && Y == other.Y && Z == other.Z; return X == other.X && Y == other.Y && Z == other.Z;
} }
return false; return false;
@ -148,7 +148,7 @@ class Vector3i {
@override @override
String toString() { String toString() {
return "<${X}, ${Y}, ${Z}>"; return "<$X, $Y, $Z>";
} }
bool inside(Vector3i min, Vector3i max) { bool inside(Vector3i min, Vector3i max) {