From 351ec0f9bf47daa7bbaa0f0bc2c999f98a512a0c Mon Sep 17 00:00:00 2001 From: xtex Date: Sun, 2 Jul 2023 11:17:37 +0800 Subject: [PATCH] feat: display entity name --- .../quaedam/projection/swarm/ProjectedPersonEntity.kt | 6 +++++- .../kotlin/quaedam/projection/swarm/ProjectedPersonShape.kt | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonEntity.kt b/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonEntity.kt index e774d4c..771426c 100644 --- a/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonEntity.kt +++ b/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonEntity.kt @@ -5,6 +5,7 @@ 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.chat.Component import net.minecraft.network.syncher.EntityDataAccessor import net.minecraft.network.syncher.EntityDataSerializers import net.minecraft.network.syncher.SynchedEntityData @@ -42,7 +43,7 @@ class ProjectedPersonEntity(entityType: EntityType, level: Le init { EntityAttributeRegistry.register(entity, ::createAttributes) - if(Platform.getEnv() == EnvType.CLIENT) { + if (Platform.getEnv() == EnvType.CLIENT) { EntityRendererRegistry.register(entity, ::ProjectedPersonRenderer) } ProjectedPersonShape @@ -95,4 +96,7 @@ class ProjectedPersonEntity(entityType: EntityType, level: Le override fun shouldShowName() = true + override fun getTypeName(): Component = shape.name.takeIf { it.isNotEmpty() }?.let { Component.literal(it) } + ?: super.getTypeName() + } \ No newline at end of file diff --git a/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonShape.kt b/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonShape.kt index cdc0d66..705a020 100644 --- a/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonShape.kt +++ b/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonShape.kt @@ -23,7 +23,7 @@ data class ProjectedPersonShape( val scaleX: Float = 1.0f, val scaleY: Float = 1.0f, val scaleZ: Float = 1.0f, - val name: String = "[DESYNC]", + val name: String = "", val skin: Int = 0, ) {