From fd069385118406cd641c802e0a3a7d166a482eee Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Tue, 14 May 2024 19:37:34 +0200 Subject: Make firmament predicates fall back to not matching --- .../features/texturepack/CustomModelOverrideParser.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/main') diff --git a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomModelOverrideParser.kt b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomModelOverrideParser.kt index 538c63f..2f5667b 100644 --- a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomModelOverrideParser.kt +++ b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomModelOverrideParser.kt @@ -11,6 +11,7 @@ import kotlinx.serialization.KSerializer import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder +import net.minecraft.item.ItemStack import net.minecraft.util.Identifier object CustomModelOverrideParser { @@ -45,13 +46,21 @@ object CustomModelOverrideParser { registerPredicateParser("item", ItemPredicate.Parser) } + private val neverPredicate = listOf( + object : FirmamentModelPredicate { + override fun test(stack: ItemStack): Boolean { + return false + } + } + ) + fun parsePredicates(predicates: JsonObject): List { val parsedPredicates = mutableListOf() for (predicateName in predicates.keySet()) { if (!predicateName.startsWith("firmament:")) continue val identifier = Identifier(predicateName) - val parser = predicateParsers[identifier] ?: continue - val parsedPredicate = parser.parse(predicates[predicateName]) ?: continue + val parser = predicateParsers[identifier] ?: return neverPredicate + val parsedPredicate = parser.parse(predicates[predicateName]) ?: return neverPredicate parsedPredicates.add(parsedPredicate) } return parsedPredicates -- cgit