diff options
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/features/texturepack/CustomModelOverrideParser.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/features/texturepack/CustomModelOverrideParser.kt | 18 |
1 files changed, 18 insertions, 0 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 ad1f436..d512dec 100644 --- a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomModelOverrideParser.kt +++ b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomModelOverrideParser.kt @@ -7,9 +7,27 @@ package moe.nea.firmament.features.texturepack import com.google.gson.JsonObject +import kotlinx.serialization.KSerializer +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder import net.minecraft.util.Identifier object CustomModelOverrideParser { + object FirmamentRootPredicateSerializer : KSerializer<FirmamentModelPredicate> { + val delegateSerializer = kotlinx.serialization.json.JsonObject.serializer() + override val descriptor: SerialDescriptor + get() = SerialDescriptor("FirmamentModelRootPredicate", delegateSerializer.descriptor) + + override fun deserialize(decoder: Decoder): FirmamentModelPredicate { + val json = decoder.decodeSerializableValue(delegateSerializer).intoGson() as JsonObject + return AndPredicate(parsePredicates(json).toTypedArray()) + } + + override fun serialize(encoder: Encoder, value: FirmamentModelPredicate) { + TODO("Cannot serialize firmament predicates") + } + } val predicateParsers = mutableMapOf<Identifier, FirmamentModelPredicateParser>() |