summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/nether
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-03-11 16:28:59 +0100
committerGitHub <noreply@github.com>2024-03-11 16:28:59 +0100
commit5b53cc7bda66be5f740749f9fd0cba23927c4d82 (patch)
tree429d423dbe3e4dec775f6894df810fba9c132bfc /src/main/java/at/hannibal2/skyhanni/features/nether
parent9637398e94e41a1bb8787d2ef5bce6b839606b57 (diff)
downloadskyhanni-5b53cc7bda66be5f740749f9fd0cba23927c4d82.tar.gz
skyhanni-5b53cc7bda66be5f740749f9fd0cba23927c4d82.tar.bz2
skyhanni-5b53cc7bda66be5f740749f9fd0cba23927c4d82.zip
Backend: RenderEntityLiving performance fix (#1127)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/nether')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt38
1 files changed, 14 insertions, 24 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt
index be8595caa..fd32f9824 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt
@@ -2,20 +2,20 @@ package at.hannibal2.skyhanni.features.nether.ashfang
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
+import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
-import at.hannibal2.skyhanni.events.RenderMobColoredEvent
-import at.hannibal2.skyhanni.events.ResetEntityHurtEvent
import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent
-import at.hannibal2.skyhanni.events.withAlpha
import at.hannibal2.skyhanni.features.combat.damageindicator.BossType
import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager
+import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy
+import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.EntityUtils.getAllNameTagsWith
import at.hannibal2.skyhanni.utils.LorenzColor
-import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.entity.monster.EntityBlaze
@@ -59,7 +59,7 @@ class AshfangBlazes {
blazeArmorStand = blazeArmorStand.editCopy {
this[entity] = armorStand
}
- blazeColor[entity] = color
+ entity setBlazeColor color
}
}
}
@@ -83,24 +83,6 @@ class AshfangBlazes {
nearAshfang = EntityUtils.getEntities<EntityArmorStand>().any { it.name.contains("Ashfang") }
}
- @SubscribeEvent
- fun onRenderMobColored(event: RenderMobColoredEvent) {
- if (!isEnabled()) return
- if (!config.highlightBlazes) return
- val entity = event.entity
- event.color = blazeColor[entity]?.toColor()?.withAlpha(40) ?: 0
- }
-
- @SubscribeEvent
- fun onResetEntityHurtTime(event: ResetEntityHurtEvent) {
- if (!isEnabled()) return
- if (!config.highlightBlazes) return
- val entity = event.entity
- if (entity in blazeColor) {
- event.shouldReset = true
- }
- }
-
@SubscribeEvent(priority = EventPriority.HIGH)
fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre<EntityLivingBase>) {
if (!isEnabled()) return
@@ -129,6 +111,14 @@ class AshfangBlazes {
}
private fun isEnabled(): Boolean {
- return LorenzUtils.inSkyBlock && DamageIndicatorManager.isBossSpawned(BossType.NETHER_ASHFANG)
+ return IslandType.CRIMSON_ISLE.isInIsland() && DamageIndicatorManager.isBossSpawned(BossType.NETHER_ASHFANG)
+ }
+
+ private infix fun EntityBlaze.setBlazeColor(color: LorenzColor) {
+ blazeColor[this] = color
+ RenderLivingEntityHelper.setEntityColorWithNoHurtTime(
+ this,
+ color.toColor().withAlpha(40),
+ ) { isEnabled() && config.highlightBlazes }
}
}