fix: registry bootstrap
This commit is contained in:
parent
7cd6fb11a7
commit
5e3df22a10
@ -36,6 +36,7 @@ object Quaedam {
|
|||||||
|
|
||||||
fun init() {
|
fun init() {
|
||||||
Projector
|
Projector
|
||||||
|
ProjectionEffectType
|
||||||
SkylightProjection
|
SkylightProjection
|
||||||
SwarmProjection
|
SwarmProjection
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import net.minecraft.resources.ResourceLocation
|
|||||||
import net.minecraft.server.level.ServerLevel
|
import net.minecraft.server.level.ServerLevel
|
||||||
import net.minecraft.world.level.Level
|
import net.minecraft.world.level.Level
|
||||||
import net.minecraft.world.level.block.state.BlockState
|
import net.minecraft.world.level.block.state.BlockState
|
||||||
import quaedam.projection.swarm.SwarmProjection
|
|
||||||
|
|
||||||
abstract class ProjectionEffect {
|
abstract class ProjectionEffect {
|
||||||
|
|
||||||
@ -39,14 +38,22 @@ data class ProjectionEffectType<T : ProjectionEffect>(val constructor: () -> T)
|
|||||||
|
|
||||||
val registryKey: ResourceKey<Registry<ProjectionEffectType<*>>> =
|
val registryKey: ResourceKey<Registry<ProjectionEffectType<*>>> =
|
||||||
ResourceKey.createRegistryKey(ResourceLocation("quaedam", "projection_effect"))
|
ResourceKey.createRegistryKey(ResourceLocation("quaedam", "projection_effect"))
|
||||||
val registry: Registry<ProjectionEffectType<*>> = BuiltInRegistries.registerSimple(registryKey) {
|
val registry: Registry<ProjectionEffectType<*>> = BuiltInRegistries.registerSimple(registryKey) { null }
|
||||||
SwarmProjection.effect.get()
|
|
||||||
}
|
val nopEffect: ProjectionEffectType<NopEffect> =
|
||||||
|
Registry.register(registry, ResourceLocation("quaedam", "nop"), ProjectionEffectType { NopEffect })
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val id: ResourceLocation by lazy { registry.getResourceKey(this).get().location() }
|
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<P : ProjectionEffect> {
|
interface ProjectionProvider<P : ProjectionEffect> {
|
||||||
|
Loading…
Reference in New Issue
Block a user