aboutsummaryrefslogtreecommitdiff
path: root/src/texturePacks/java/moe/nea/firmament/features/texturepack/FirmamentRootPredicateSerializer.kt
blob: 0b8ae8efa9506dc6b367dcd74bd8f203dee62771 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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 moe.nea.firmament.features.texturepack.predicates.AndPredicate

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(CustomModelOverrideParser.parsePredicates(json).toTypedArray())
	}

	override fun serialize(encoder: Encoder, value: FirmamentModelPredicate) {
		TODO("Cannot serialize firmament predicates")
	}
}