From aab9e09e30667ac495eab359ecc971f4608ac7d1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Feb 2023 00:31:49 +0700 Subject: [PATCH] damn --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 2 +- .../dbotthepony/mc/otm/core/util/Savetables.kt | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt index 40bf618b5..1da14f61f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt @@ -418,7 +418,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc protected val savetables = Savetables() protected inline fun > savetable(property: KProperty0, name: String = property.name) { - savetables.Stateful(property, name, T::class.java) + savetables.stateful(property, name, T::class.java) } override fun saveAdditional(nbt: CompoundTag) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt index ea41fab76..44c2ddc36 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt @@ -28,14 +28,22 @@ class Savetables : INBTSerializable { fun validate() } - inline fun , reified T : Tag> stateful(getter: Supplier, name: String): Stateful { - return Stateful(getter, name, T::class.java) + inline fun , reified T : Tag> stateful(getter: Supplier, name: String): Stateful { + return stateful(getter, name, T::class.java) + } + + inline fun , reified T : Tag> stateful(getter: KProperty0, name: String = getter.name): Stateful { + return stateful(getter, name, T::class.java) + } + + fun , T : Tag> stateful(getter: Supplier, name: String, type: Class): Stateful { + return Stateful(getter, name, type) .withSerializer { it.serializeNBT() } .withDeserializer { v, t -> v.deserializeNBT(t) } } - inline fun , reified T : Tag> stateful(getter: KProperty0, name: String = getter.name): Stateful { - return Stateful(getter, name, T::class.java) + fun , T : Tag> stateful(getter: KProperty0, name: String = getter.name, type: Class): Stateful { + return Stateful(getter, name, type) .withSerializer { it.serializeNBT() } .withDeserializer { v, t -> v.deserializeNBT(t) } }