From 7e3611bc9e6505a90b3442290d5d5d3099e7524a Mon Sep 17 00:00:00 2001 From: xtex Date: Sun, 2 Jul 2023 10:54:31 +0800 Subject: [PATCH] fix: dedicated server loading --- .../quaedam/projection/swarm/ProjectedPersonEntity.kt | 6 +++++- .../quaedam/projection/swarm/ProjectedPersonShape.kt | 11 +++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonEntity.kt b/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonEntity.kt index e2f0bff..e774d4c 100644 --- a/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonEntity.kt +++ b/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonEntity.kt @@ -1,7 +1,9 @@ package quaedam.projection.swarm +import dev.architectury.platform.Platform import dev.architectury.registry.client.level.entity.EntityRendererRegistry import dev.architectury.registry.level.entity.EntityAttributeRegistry +import net.fabricmc.api.EnvType import net.minecraft.nbt.CompoundTag import net.minecraft.network.syncher.EntityDataAccessor import net.minecraft.network.syncher.EntityDataSerializers @@ -40,7 +42,9 @@ class ProjectedPersonEntity(entityType: EntityType, level: Le init { EntityAttributeRegistry.register(entity, ::createAttributes) - EntityRendererRegistry.register(entity, ::ProjectedPersonRenderer) + if(Platform.getEnv() == EnvType.CLIENT) { + EntityRendererRegistry.register(entity, ::ProjectedPersonRenderer) + } ProjectedPersonShape } diff --git a/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonShape.kt b/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonShape.kt index f0dbfde..16a461b 100644 --- a/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonShape.kt +++ b/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonShape.kt @@ -1,6 +1,8 @@ package quaedam.projection.swarm import dev.architectury.registry.ReloadListenerRegistry +import net.fabricmc.api.EnvType +import net.fabricmc.api.Environment import net.minecraft.nbt.CompoundTag import net.minecraft.resources.ResourceLocation import net.minecraft.server.packs.PackType @@ -40,9 +42,9 @@ data class ProjectedPersonShape( fun create(seed: Long) = create(Random(seed)) fun create(rand: Random) = ProjectedPersonShape( - scaleX = rand.nextInt(0..6) * 0.1f + 0.7f, - scaleY = rand.nextInt(0..6) * 0.1f + 0.7f, - scaleZ = rand.nextInt(0..2) * 0.1f + 0.9f, + scaleX = rand.nextInt(0..6 * 4) * 0.025f + 0.7f, + scaleY = rand.nextInt(0..6 * 4) * 0.025f + 0.7f, + scaleZ = rand.nextInt(0..2 * 4) * 0.025f + 0.9f, name = Names.random(rand), skin = Skins.random(rand), ) @@ -69,6 +71,7 @@ data class ProjectedPersonShape( val id = ResourceLocation("quaedam", "projected-person-names") + @Environment(EnvType.SERVER) var names = emptySet() init { @@ -106,7 +109,7 @@ data class ProjectedPersonShape( val id = ResourceLocation("quaedam", "skins") - // only available on client + @Environment(EnvType.CLIENT) var skins = emptyList() init {