From 5e3df22a1054a8571e0fbba6a19bd37f84dd5cdb Mon Sep 17 00:00:00 2001 From: xtex Date: Sun, 2 Jul 2023 18:06:15 +0800 Subject: [PATCH] fix: registry bootstrap --- common/src/main/kotlin/quaedam/Quaedam.kt | 1 + .../kotlin/quaedam/projection/ProjectionEffect.kt | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/common/src/main/kotlin/quaedam/Quaedam.kt b/common/src/main/kotlin/quaedam/Quaedam.kt index 157e29c..a61fed5 100644 --- a/common/src/main/kotlin/quaedam/Quaedam.kt +++ b/common/src/main/kotlin/quaedam/Quaedam.kt @@ -36,6 +36,7 @@ object Quaedam { fun init() { Projector + ProjectionEffectType SkylightProjection SwarmProjection diff --git a/common/src/main/kotlin/quaedam/projection/ProjectionEffect.kt b/common/src/main/kotlin/quaedam/projection/ProjectionEffect.kt index 0be05b7..7fa50e1 100644 --- a/common/src/main/kotlin/quaedam/projection/ProjectionEffect.kt +++ b/common/src/main/kotlin/quaedam/projection/ProjectionEffect.kt @@ -9,7 +9,6 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState -import quaedam.projection.swarm.SwarmProjection abstract class ProjectionEffect { @@ -39,14 +38,22 @@ data class ProjectionEffectType(val constructor: () -> T) val registryKey: ResourceKey>> = ResourceKey.createRegistryKey(ResourceLocation("quaedam", "projection_effect")) - val registry: Registry> = BuiltInRegistries.registerSimple(registryKey) { - SwarmProjection.effect.get() - } + val registry: Registry> = BuiltInRegistries.registerSimple(registryKey) { null } + + val nopEffect: ProjectionEffectType = + Registry.register(registry, ResourceLocation("quaedam", "nop"), ProjectionEffectType { NopEffect }) } val id: ResourceLocation by lazy { registry.getResourceKey(this).get().location() } + // To hide the "unable to bootstrap quaedam:projection_effect" error log + object NopEffect : ProjectionEffect() { + override val type get() = nopEffect + override fun toNbt(tag: CompoundTag) {} + override fun fromNbt(tag: CompoundTag) {} + } + } interface ProjectionProvider

{