aboutsummaryrefslogtreecommitdiff
path: root/src/texturePacks/java/moe/nea/firmament/features/texturepack/FirmamentRootPredicateSerializer.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-12-07 13:26:03 +0100
committerLinnea Gräf <nea@nea.moe>2024-12-07 13:26:03 +0100
commitbf7795df22ca7892fae1238403feebb57c005562 (patch)
tree3a49db5bade38498f976321b6e9008203f2d4d3b /src/texturePacks/java/moe/nea/firmament/features/texturepack/FirmamentRootPredicateSerializer.kt
parentcdb5e60f52eea9030af9ca2d4a49913664023965 (diff)
downloadFirmament-bf7795df22ca7892fae1238403feebb57c005562.tar.gz
Firmament-bf7795df22ca7892fae1238403feebb57c005562.tar.bz2
Firmament-bf7795df22ca7892fae1238403feebb57c005562.zip
WIP: Port to compilation on 1.21.4
Diffstat (limited to 'src/texturePacks/java/moe/nea/firmament/features/texturepack/FirmamentRootPredicateSerializer.kt')
-rw-r--r--src/texturePacks/java/moe/nea/firmament/features/texturepack/FirmamentRootPredicateSerializer.kt23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/texturePacks/java/moe/nea/firmament/features/texturepack/FirmamentRootPredicateSerializer.kt b/src/texturePacks/java/moe/nea/firmament/features/texturepack/FirmamentRootPredicateSerializer.kt
new file mode 100644
index 0000000..0b8ae8e
--- /dev/null
+++ b/src/texturePacks/java/moe/nea/firmament/features/texturepack/FirmamentRootPredicateSerializer.kt
@@ -0,0 +1,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")
+ }
+}