Update boolean provider to use MRegistries
This commit is contained in:
parent
9ee561d0fd
commit
ca67e796da
@ -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<T : BooleanProvider> {
|
||||
@ -123,14 +122,7 @@ interface BooleanProvider {
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val registryHolder = RegistryDelegate<Type<*>>("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<BooleanProvider> 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)
|
||||
}
|
||||
}
|
||||
|
@ -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) }
|
||||
}
|
||||
|
@ -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<AndroidResearchResult.Type<*>>("android_research_result")
|
||||
val ANDROID_FEATURE = k<AndroidFeatureType<*>>("android_feature")
|
||||
val STACK_TYPE = k<StorageStack.Type<*>>("stack_type")
|
||||
val BOOLEAN_PROVIDER = k<BooleanProvider.Type<*>>("boolean_provider")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user