From ca67e796da28ed0ec48715ebbb3e1844af31d39b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 24 Mar 2025 14:01:32 +0700 Subject: [PATCH] Update boolean provider to use MRegistries --- .../mc/otm/data/world/BooleanProvider.kt | 17 ++++------------- .../mc/otm/registry/MBuiltInRegistries.kt | 4 ++++ .../dbotthepony/mc/otm/registry/MRegistries.kt | 2 ++ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/world/BooleanProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/world/BooleanProvider.kt index 61cc7d0c9..f31765ebf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/world/BooleanProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/world/BooleanProvider.kt @@ -5,11 +5,10 @@ import com.mojang.serialization.MapCodec import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.util.RandomSource import net.neoforged.bus.api.IEventBus -import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.data.codec.inRange +import ru.dbotthepony.mc.otm.registry.MBuiltInRegistries import ru.dbotthepony.mc.otm.registry.MDeferredRegister -import ru.dbotthepony.mc.otm.registry.RegistryDelegate +import ru.dbotthepony.mc.otm.registry.MRegistries interface BooleanProvider { interface Type { @@ -123,14 +122,7 @@ interface BooleanProvider { } companion object { - private val registryHolder = RegistryDelegate>("boolean_provider") { - defaultKey(ResourceLocation(OverdriveThatMatters.MOD_ID, "zero")) - } - - val registry by registryHolder - val registryKey get() = registryHolder.key - - private val registrar = MDeferredRegister(registryKey) + private val registrar = MDeferredRegister(MRegistries.BOOLEAN_PROVIDER) init { registrar.register("unbiased") { Unbiased.Companion } @@ -140,11 +132,10 @@ interface BooleanProvider { } val CODEC: Codec by lazy { - registry.byNameCodec().dispatch({ it.type }, { it.codec }) + MBuiltInRegistries.BOOLEAN_PROVIDER.byNameCodec().dispatch({ it.type }, { it.codec }) } internal fun register(bus: IEventBus) { - bus.addListener(registryHolder::build) registrar.register(bus) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBuiltInRegistries.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBuiltInRegistries.kt index 462770f23..699e7497e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBuiltInRegistries.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBuiltInRegistries.kt @@ -51,6 +51,10 @@ object MBuiltInRegistries { val ANDROID_FEATURE by Delegate(MRegistries.ANDROID_FEATURE) { sync(true) } val STACK_TYPE by Delegate(MRegistries.STACK_TYPE) + val BOOLEAN_PROVIDER by Delegate(MRegistries.BOOLEAN_PROVIDER) { + defaultKey(ResourceLocation(OverdriveThatMatters.MOD_ID, "false")) + } + internal fun register(bus: IEventBus) { delegates.forEach { bus.addListener(it::build) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistries.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistries.kt index 5533b8ead..3fab1b53e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistries.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistries.kt @@ -4,6 +4,7 @@ import net.minecraft.core.Registry import net.minecraft.resources.ResourceKey import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.core.ResourceLocation +import ru.dbotthepony.mc.otm.data.world.BooleanProvider import ru.dbotthepony.mc.otm.data.world.DecimalProvider import ru.dbotthepony.mc.otm.matter.AbstractRegistryAction import ru.dbotthepony.mc.otm.matter.IMatterFunction @@ -26,4 +27,5 @@ object MRegistries { val ANDROID_RESEARCH_RESULT = k>("android_research_result") val ANDROID_FEATURE = k>("android_feature") val STACK_TYPE = k>("stack_type") + val BOOLEAN_PROVIDER = k>("boolean_provider") }