diff options
author | Linnea Gräf <nea@nea.moe> | 2024-05-14 19:37:34 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-05-14 19:37:34 +0200 |
commit | fd069385118406cd641c802e0a3a7d166a482eee (patch) | |
tree | 6a00752015a0cf3bd4ad8871a14a3cde9a39f955 /src/main/kotlin/moe/nea/firmament | |
parent | 21e84ba59f253a78fcf0ba6187ba27ba52114ee6 (diff) | |
download | Firmament-fd069385118406cd641c802e0a3a7d166a482eee.tar.gz Firmament-fd069385118406cd641c802e0a3a7d166a482eee.tar.bz2 Firmament-fd069385118406cd641c802e0a3a7d166a482eee.zip |
Make firmament predicates fall back to not matching
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/features/texturepack/CustomModelOverrideParser.kt | 13 |
1 files changed, 11 insertions, 2 deletions
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<FirmamentModelPredicate> { val parsedPredicates = mutableListOf<FirmamentModelPredicate>() 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 |