aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/util
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-05-11 03:28:05 +0200
committerLinnea Gräf <nea@nea.moe>2024-05-14 18:45:59 +0200
commit7682534f6fd139b75f24c79b76098fe05f0fa0fe (patch)
tree34d94c8fd7b531da128ff0130bf463393e2560e0 /src/main/kotlin/moe/nea/firmament/util
parent53dc0c3b0a758ce2afff2637a5a5f22aa1733c56 (diff)
downloadfirmament-7682534f6fd139b75f24c79b76098fe05f0fa0fe.tar.gz
firmament-7682534f6fd139b75f24c79b76098fe05f0fa0fe.tar.bz2
firmament-7682534f6fd139b75f24c79b76098fe05f0fa0fe.zip
Add custom global textures
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/util')
-rw-r--r--src/main/kotlin/moe/nea/firmament/util/IdentifierSerializer.kt28
-rw-r--r--src/main/kotlin/moe/nea/firmament/util/LogIfNull.kt13
2 files changed, 41 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/IdentifierSerializer.kt b/src/main/kotlin/moe/nea/firmament/util/IdentifierSerializer.kt
new file mode 100644
index 0000000..3c1aa52
--- /dev/null
+++ b/src/main/kotlin/moe/nea/firmament/util/IdentifierSerializer.kt
@@ -0,0 +1,28 @@
+/*
+ * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+package moe.nea.firmament.util
+
+import kotlinx.serialization.KSerializer
+import kotlinx.serialization.builtins.serializer
+import kotlinx.serialization.descriptors.SerialDescriptor
+import kotlinx.serialization.encoding.Decoder
+import kotlinx.serialization.encoding.Encoder
+import net.minecraft.util.Identifier
+
+object IdentifierSerializer : KSerializer<Identifier> {
+ val delegateSerializer = String.serializer()
+ override val descriptor: SerialDescriptor
+ get() = SerialDescriptor("Identifier", delegateSerializer.descriptor)
+
+ override fun deserialize(decoder: Decoder): Identifier {
+ return Identifier(decoder.decodeSerializableValue(delegateSerializer))
+ }
+
+ override fun serialize(encoder: Encoder, value: Identifier) {
+ encoder.encodeSerializableValue(delegateSerializer, value.toString())
+ }
+}
diff --git a/src/main/kotlin/moe/nea/firmament/util/LogIfNull.kt b/src/main/kotlin/moe/nea/firmament/util/LogIfNull.kt
new file mode 100644
index 0000000..b0476ee
--- /dev/null
+++ b/src/main/kotlin/moe/nea/firmament/util/LogIfNull.kt
@@ -0,0 +1,13 @@
+/*
+ * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+package moe.nea.firmament.util
+
+
+fun runNull(block: () -> Unit): Nothing? {
+ block()
+ return null
+}