Skip to content

Commit

Permalink
Fix legacy tag parser prefering untyped doubles to ints
Browse files Browse the repository at this point in the history
This fixes an incompatibility caused by SkyblockerMod/Skyblocker#462
  • Loading branch information
nea89o committed Dec 29, 2023
1 parent 7456887 commit bd0712a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/kotlin/moe/nea/firmament/util/LegacyTagParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,6 @@ class LegacyTagParser private constructor(string: String) {
if (textForm.isEmpty()) {
racer.error("Expected numeric tag (starting with either -, +, . or a digit")
}
val doubleMatch = Patterns.DOUBLE.matchEntire(textForm) ?: Patterns.DOUBLE_UNTYPED.matchEntire(textForm)
if (doubleMatch != null) {
return NbtDouble.of(doubleMatch.groups[1]!!.value.toDouble())
}
val floatMatch = Patterns.FLOAT.matchEntire(textForm)
if (floatMatch != null) {
return NbtFloat.of(floatMatch.groups[1]!!.value.toFloat())
Expand All @@ -232,6 +228,10 @@ class LegacyTagParser private constructor(string: String) {
if (integerMatch != null) {
return NbtInt.of(integerMatch.groups[1]!!.value.toInt())
}
val doubleMatch = Patterns.DOUBLE.matchEntire(textForm) ?: Patterns.DOUBLE_UNTYPED.matchEntire(textForm)
if (doubleMatch != null) {
return NbtDouble.of(doubleMatch.groups[1]!!.value.toDouble())
}
throw IllegalStateException("Could not properly parse numeric tag '$textForm', despite passing rough verification. This is a bug in the LegacyTagParser")
}

Expand Down

0 comments on commit bd0712a

Please sign in to comment.