diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-08-02 11:08:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-02 11:08:16 +0200 |
commit | 7a6c175ead0be52201f62d116dba953e5e112fa8 (patch) | |
tree | f984bdb70cafcec2b1ef1787e7ebee084ef98001 /src/main/java/at/hannibal2/skyhanni/data | |
parent | 32e7a457983a0a6050d7db8bd99dec52a5164979 (diff) | |
download | skyhanni-7a6c175ead0be52201f62d116dba953e5e112fa8.tar.gz skyhanni-7a6c175ead0be52201f62d116dba953e5e112fa8.tar.bz2 skyhanni-7a6c175ead0be52201f62d116dba953e5e112fa8.zip |
Fix: Contributor nametag flicker Patcher (#2296)
Co-authored-by: nea <nea@nea.moe>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/EntityData.kt | 11 |
1 files changed, 5 insertions, 6 deletions
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<EntityLivingBase, Int>() - private val nametagCache = TimeLimitedCache<Entity, IChatComponent>(50.milliseconds) + private val nametagCache = TimeLimitedCache<Entity, ChatComponentText>(50.milliseconds) @SubscribeEvent fun onTick(event: LorenzTickEvent) { @@ -95,11 +94,11 @@ object EntityData { } @JvmStatic - fun getDisplayName(entity: Entity, ci: CallbackInfoReturnable<IChatComponent>) { - 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 |