From 5b53cc7bda66be5f740749f9fd0cba23927c4d82 Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Mon, 11 Mar 2024 16:28:59 +0100 Subject: Backend: RenderEntityLiving performance fix (#1127) --- .../features/combat/mobs/AreaMiniBossFeatures.kt | 5 ++- .../skyhanni/features/combat/mobs/MobHighlight.kt | 38 +++++++++++++--------- 2 files changed, 25 insertions(+), 18 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/combat') diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AreaMiniBossFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AreaMiniBossFeatures.kt index 977b38259..06802413a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AreaMiniBossFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AreaMiniBossFeatures.kt @@ -5,8 +5,8 @@ import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.withAlpha import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.LorenzColor @@ -52,9 +52,8 @@ class AreaMiniBossFeatures { if (config.areaBossHighlight) { val color = bossType.color.toColor().withAlpha(bossType.colorOpacity) - RenderLivingEntityHelper.setEntityColor(entity, color) + RenderLivingEntityHelper.setEntityColorWithNoHurtTime(entity, color) { config.areaBossHighlight && SlayerAPI.isInAnyArea } - RenderLivingEntityHelper.setNoHurtTime(entity) { config.areaBossHighlight && SlayerAPI.isInAnyArea } } // TODO add sound diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt index d7ecc8f52..f10d4ef2c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt @@ -3,8 +3,8 @@ package at.hannibal2.skyhanni.features.combat.mobs import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent -import at.hannibal2.skyhanni.events.withAlpha import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.EntityUtils.hasNameTagWith import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils @@ -28,9 +28,11 @@ class MobHighlight { val entity = event.entity val baseMaxHealth = entity.baseMaxHealth if (config.corruptedMobHighlight && event.health == baseMaxHealth * 3) { - RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.DARK_PURPLE.toColor().withAlpha(127)) + RenderLivingEntityHelper.setEntityColorWithNoHurtTime( + entity, + LorenzColor.DARK_PURPLE.toColor().withAlpha(127) + ) { config.corruptedMobHighlight } - RenderLivingEntityHelper.setNoHurtTime(entity) { config.corruptedMobHighlight } } } @@ -41,15 +43,19 @@ class MobHighlight { val entity = event.entity val maxHealth = event.maxHealth if (config.arachneKeeperHighlight && (maxHealth == 3_000 || maxHealth == 12_000) && entity is EntityCaveSpider) { - RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.DARK_BLUE.toColor().withAlpha(127)) + RenderLivingEntityHelper.setEntityColorWithNoHurtTime( + entity, + LorenzColor.DARK_BLUE.toColor().withAlpha(127) + ) { config.arachneKeeperHighlight } - RenderLivingEntityHelper.setNoHurtTime(entity) { config.arachneKeeperHighlight } } if (config.corleoneHighlighter && maxHealth == 1_000_000 && entity is EntityOtherPlayerMP && entity.name == "Team Treasurite") { - RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.DARK_PURPLE.toColor().withAlpha(127)) + RenderLivingEntityHelper.setEntityColorWithNoHurtTime( + entity, + LorenzColor.DARK_PURPLE.toColor().withAlpha(127) + ) { config.corleoneHighlighter } - RenderLivingEntityHelper.setNoHurtTime(entity) { config.corleoneHighlighter } } if (entity is EntityEnderman) { @@ -57,17 +63,21 @@ class MobHighlight { val isZealot = maxHealth == 13_000 || maxHealth == 13_000 * 4 // runic val isBruiser = maxHealth == 65_000 || maxHealth == 65_000 * 4 // runic if (isZealot || isBruiser) { - RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.DARK_AQUA.toColor().withAlpha(127)) + RenderLivingEntityHelper.setEntityColorWithNoHurtTime( + entity, + LorenzColor.DARK_AQUA.toColor().withAlpha(127) + ) { config.zealotBruiserHighlighter } - RenderLivingEntityHelper.setNoHurtTime(entity) { config.zealotBruiserHighlighter } } } // Special Zealots are not impacted by derpy if (config.specialZealotHighlighter && maxHealth.ignoreDerpy() == 2_000) { - RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.DARK_RED.toColor().withAlpha(50)) + RenderLivingEntityHelper.setEntityColorWithNoHurtTime( + entity, + LorenzColor.DARK_RED.toColor().withAlpha(50) + ) { config.specialZealotHighlighter } - RenderLivingEntityHelper.setNoHurtTime(entity) { config.specialZealotHighlighter } } } @@ -91,14 +101,12 @@ class MobHighlight { } private fun markArachneMinis(entity: EntityLivingBase) { - RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.GOLD.toColor().withAlpha(50)) + RenderLivingEntityHelper.setEntityColorWithNoHurtTime(entity, LorenzColor.GOLD.toColor().withAlpha(50)) { config.arachneBossHighlighter } - RenderLivingEntityHelper.setNoHurtTime(entity) { config.arachneBossHighlighter } } private fun markArachne(entity: EntityLivingBase) { - RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.RED.toColor().withAlpha(50)) + RenderLivingEntityHelper.setEntityColorWithNoHurtTime(entity, LorenzColor.RED.toColor().withAlpha(50)) { config.arachneBossHighlighter } - RenderLivingEntityHelper.setNoHurtTime(entity) { config.arachneBossHighlighter } } } -- cgit