From bd0712adb0eb9c12a97a201b6df52fbdad0f0dba Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Fri, 29 Dec 2023 19:14:55 +0100 Subject: Fix legacy tag parser prefering untyped doubles to ints This fixes an incompatibility caused by https://github.com/SkyblockerMod/Skyblocker/issues/462 --- src/main/kotlin/moe/nea/firmament/util/LegacyTagParser.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main/kotlin/moe/nea') diff --git a/src/main/kotlin/moe/nea/firmament/util/LegacyTagParser.kt b/src/main/kotlin/moe/nea/firmament/util/LegacyTagParser.kt index 80e1ea4..47d60ac 100644 --- a/src/main/kotlin/moe/nea/firmament/util/LegacyTagParser.kt +++ b/src/main/kotlin/moe/nea/firmament/util/LegacyTagParser.kt @@ -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()) @@ -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") } -- cgit