diff options
author | Linnea Gräf <nea@nea.moe> | 2024-03-03 18:04:45 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-03-03 18:04:45 +0100 |
commit | b025b06b6b799b16cfcfb26ee8ffad27879a1bfb (patch) | |
tree | 42053f84a198dd826235b403caa63f351897debf /src/main/kotlin/moe/nea/firmament/features/texturepack/NotPredicate.kt | |
parent | 3bfec3033e9d905514d5c1c6c62953c2a1646af0 (diff) | |
download | firmament-b025b06b6b799b16cfcfb26ee8ffad27879a1bfb.tar.gz firmament-b025b06b6b799b16cfcfb26ee8ffad27879a1bfb.tar.bz2 firmament-b025b06b6b799b16cfcfb26ee8ffad27879a1bfb.zip |
Add not predicate and docs to custom predicates
[no changelog]
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/features/texturepack/NotPredicate.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/features/texturepack/NotPredicate.kt | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/features/texturepack/NotPredicate.kt b/src/main/kotlin/moe/nea/firmament/features/texturepack/NotPredicate.kt new file mode 100644 index 0000000..9d584cf --- /dev/null +++ b/src/main/kotlin/moe/nea/firmament/features/texturepack/NotPredicate.kt @@ -0,0 +1,23 @@ +/* + * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe> + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.features.texturepack + +import com.google.gson.JsonElement +import com.google.gson.JsonObject +import net.minecraft.item.ItemStack + +class NotPredicate(val children: Array<FirmamentModelPredicate>) : FirmamentModelPredicate { + override fun test(stack: ItemStack): Boolean { + return children.none { it.test(stack) } + } + + object Parser : FirmamentModelPredicateParser { + override fun parse(jsonElement: JsonElement): FirmamentModelPredicate { + return NotPredicate(CustomModelOverrideParser.parsePredicates(jsonElement as JsonObject).toTypedArray()) + } + } +} |