summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/summonings
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/summonings
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/summonings')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt
index 93a79c4ea..6b9e11ec7 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt
@@ -6,11 +6,10 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
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.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzColor
@@ -114,6 +113,7 @@ class SummoningMobManager {
.distance(playerLocation) < 10 && it.ticksExisted < 2
}.forEach {
summoningMobs[it] = SummoningMob(System.currentTimeMillis(), name = "Mob")
+ it.setColor(LorenzColor.GREEN)
updateData()
if (summoningMobs.size == summoningsSpawned) {
searchMobs = false
@@ -133,6 +133,7 @@ class SummoningMobManager {
val name = summoningMob.name
if (currentHealth == 0) {
summoningMobs.remove(entityLiving)
+ entityLiving.setColor(null)
ChatUtils.chat("Your Summoning Mob just §cdied!")
continue
}
@@ -183,24 +184,6 @@ class SummoningMobManager {
}
@SubscribeEvent
- fun onRenderMobColored(event: RenderMobColoredEvent) {
- if (config.summoningMobColored) {
- val entity = event.entity
- if (entity is EntityLiving && entity in summoningMobs.keys) {
- event.color = LorenzColor.GREEN.toColor().withAlpha(127)
- }
- }
- }
-
- @SubscribeEvent
- fun onResetEntityHurtTime(event: ResetEntityHurtEvent) {
- val entity = event.entity
- if (config.summoningMobColored && entity in summoningMobs.keys) {
- event.shouldReset = true
- }
- }
-
- @SubscribeEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
event.move(2, "summonings", "combat.summonings")
}
@@ -222,4 +205,15 @@ class SummoningMobManager {
var name: String = "",
var lastDisplayName: String = "",
)
+
+ private infix fun EntityLivingBase.setColor(color: LorenzColor?) {
+ if (color != null) {
+ RenderLivingEntityHelper.setEntityColorWithNoHurtTime(
+ this,
+ color.toColor().withAlpha(127),
+ ) { isEnabled() && config.summoningMobColored }
+ } else {
+ RenderLivingEntityHelper.removeCustomRender(this)
+ }
+ }
}