From 7a6c175ead0be52201f62d116dba953e5e112fa8 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Fri, 2 Aug 2024 11:08:16 +0200 Subject: Fix: Contributor nametag flicker Patcher (#2296) Co-authored-by: nea --- src/main/java/at/hannibal2/skyhanni/data/EntityData.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/data') diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt index c8e90fd27..c4e5fd7e7 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt @@ -23,16 +23,15 @@ import net.minecraft.entity.item.EntityItem import net.minecraft.entity.item.EntityItemFrame import net.minecraft.entity.item.EntityXPOrb import net.minecraft.network.play.server.S1CPacketEntityMetadata -import net.minecraft.util.IChatComponent +import net.minecraft.util.ChatComponentText import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable import kotlin.time.Duration.Companion.milliseconds @SkyHanniModule object EntityData { private val maxHealthMap = mutableMapOf() - private val nametagCache = TimeLimitedCache(50.milliseconds) + private val nametagCache = TimeLimitedCache(50.milliseconds) @SubscribeEvent fun onTick(event: LorenzTickEvent) { @@ -95,11 +94,11 @@ object EntityData { } @JvmStatic - fun getDisplayName(entity: Entity, ci: CallbackInfoReturnable) { - ci.returnValue = postRenderNametag(entity, ci.returnValue) + fun getDisplayName(entity: Entity, oldValue: ChatComponentText): ChatComponentText { + return postRenderNametag(entity, oldValue) } - private fun postRenderNametag(entity: Entity, chatComponent: IChatComponent) = nametagCache.getOrPut(entity) { + private fun postRenderNametag(entity: Entity, chatComponent: ChatComponentText) = nametagCache.getOrPut(entity) { val event = EntityDisplayNameEvent(entity, chatComponent) event.postAndCatch() event.chatComponent -- cgit