aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/slayer
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/slayer
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/slayer')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerMiniBossFeatures.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/HellionShieldHelper.kt28
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt54
4 files changed, 38 insertions, 54 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerMiniBossFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerMiniBossFeatures.kt
index bdfc7bb00..5637ed6b8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerMiniBossFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerMiniBossFeatures.kt
@@ -4,10 +4,10 @@ import at.hannibal2.skyhanni.SkyHanniMod
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.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.hasMaxHealth
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
@@ -40,9 +40,8 @@ class SlayerMiniBossFeatures {
if (bossType.clazz != entity.javaClass) continue
miniBosses = miniBosses.editCopy { add(entity) }
- RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.AQUA.toColor().withAlpha(127))
+ RenderLivingEntityHelper.setEntityColorWithNoHurtTime(entity, LorenzColor.AQUA.toColor().withAlpha(127))
{ config.slayerMinibossHighlight }
- RenderLivingEntityHelper.setNoHurtTime(entity) { config.slayerMinibossHighlight }
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt
index 474afc6cf..011f181ce 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt
@@ -9,12 +9,12 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.ReceiveParticleEvent
import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent
-import at.hannibal2.skyhanni.events.withAlpha
import at.hannibal2.skyhanni.features.rift.RiftAPI
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy
import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor
+import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.EntityUtils.canBeSeen
@@ -198,8 +198,7 @@ object VampireSlayerFeatures {
}
if (shouldRender) {
- RenderLivingEntityHelper.setEntityColor(this, color) { isEnabled() }
- RenderLivingEntityHelper.setNoHurtTime(this) { isEnabled() }
+ RenderLivingEntityHelper.setEntityColorWithNoHurtTime(this, color) { isEnabled() }
entityList.add(this)
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/HellionShieldHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/HellionShieldHelper.kt
index 125893d6f..24fda1ae8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/HellionShieldHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/HellionShieldHelper.kt
@@ -2,9 +2,8 @@ package at.hannibal2.skyhanni.features.slayer.blaze
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
-import at.hannibal2.skyhanni.events.RenderMobColoredEvent
-import at.hannibal2.skyhanni.events.ResetEntityHurtEvent
-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.LorenzUtils
import net.minecraft.entity.EntityLiving
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -17,24 +16,6 @@ class HellionShieldHelper {
}
@SubscribeEvent
- fun onRenderMobColored(event: RenderMobColoredEvent) {
- if (!LorenzUtils.inSkyBlock) return
- if (!SkyHanniMod.feature.slayer.blazes.hellion.coloredMobs) return
-
- val shield = hellionShieldMobs.getOrDefault(event.entity, null) ?: return
- event.color = shield.color.toColor().withAlpha(80)
- }
-
- @SubscribeEvent
- fun onResetEntityHurtTime(event: ResetEntityHurtEvent) {
- if (!LorenzUtils.inSkyBlock) return
- if (!SkyHanniMod.feature.slayer.blazes.hellion.coloredMobs) return
-
- hellionShieldMobs.getOrDefault(event.entity, null) ?: return
- event.shouldReset = true
- }
-
- @SubscribeEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
event.move(3, "slayer.blazeColoredMobs", "slayer.blazes.hellion.coloredMobs")
}
@@ -43,7 +24,12 @@ class HellionShieldHelper {
fun EntityLiving.setHellionShield(shield: HellionShield?) {
if (shield != null) {
HellionShieldHelper.hellionShieldMobs[this] = shield
+ RenderLivingEntityHelper.setEntityColorWithNoHurtTime(
+ this,
+ shield.color.toColor().withAlpha(80)
+ ) { LorenzUtils.inSkyBlock && SkyHanniMod.feature.slayer.blazes.hellion.coloredMobs }
} else {
HellionShieldHelper.hellionShieldMobs.remove(this)
+ RenderLivingEntityHelper.removeCustomRender(this)
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt
index 36d785d2b..fb6b57bab 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt
@@ -7,12 +7,12 @@ import at.hannibal2.skyhanni.events.CheckRenderEntityEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
-import at.hannibal2.skyhanni.events.RenderMobColoredEvent
import at.hannibal2.skyhanni.events.ServerBlockChangeEvent
-import at.hannibal2.skyhanni.events.withAlpha
+import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy
import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor
+import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
import at.hannibal2.skyhanni.utils.EntityUtils.canBeSeen
import at.hannibal2.skyhanni.utils.EntityUtils.getBlockInHand
import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
@@ -43,8 +43,8 @@ class EndermanSlayerFeatures {
private val config get() = SkyHanniMod.feature.slayer.endermen
private val beaconConfig get() = config.beacon
private val endermenWithBeacons = mutableListOf<EntityEnderman>()
- private var flyingBeacons = listOf<EntityArmorStand>()
- private val nukekubiSkulls = mutableListOf<EntityArmorStand>()
+ private val flyingBeacons = mutableSetOf<EntityArmorStand>()
+ private val nukekubiSkulls = mutableSetOf<EntityArmorStand>()
private var sittingBeacon = mapOf<LorenzVec, SimpleTimeMark>()
private val logger = LorenzLogger("slayer/enderman")
private val nukekubiSkulTexture =
@@ -65,8 +65,12 @@ class EndermanSlayerFeatures {
if (showBeacon()) {
val stack = entity.inventory[4] ?: return
if (stack.name == "Beacon" && entity.canBeSeen(15.0)) {
- flyingBeacons = flyingBeacons.editCopy {
- add(entity)
+ flyingBeacons.add(entity)
+ RenderLivingEntityHelper.setEntityColor(
+ entity,
+ beaconConfig.beaconColor.toChromaColor().withAlpha(1)
+ ) {
+ beaconConfig.highlightBeacon
}
if (beaconConfig.showWarning) {
LorenzUtils.sendTitle("ยง4Beacon", 2.seconds)
@@ -77,6 +81,10 @@ class EndermanSlayerFeatures {
if (config.highlightNukekebi && entity.inventory.any { it?.getSkullTexture() == nukekubiSkulTexture } && entity !in nukekubiSkulls) {
nukekubiSkulls.add(entity)
+ RenderLivingEntityHelper.setEntityColor(
+ entity,
+ LorenzColor.GOLD.toColor().withAlpha(1)
+ ) { config.highlightNukekebi }
logger.log("Added Nukekubi skulls at ${entity.getLorenzVec()}")
}
}
@@ -89,19 +97,6 @@ class EndermanSlayerFeatures {
private fun showBeacon() = beaconConfig.highlightBeacon || beaconConfig.showWarning || beaconConfig.showLine
@SubscribeEvent
- fun onRenderMobColored(event: RenderMobColoredEvent) {
- if (!IslandType.THE_END.isInIsland()) return
-
- if (beaconConfig.highlightBeacon && event.entity in flyingBeacons) {
- event.color = beaconConfig.beaconColor.toChromaColor().withAlpha(1)
- }
-
- if (config.highlightNukekebi && event.entity in nukekubiSkulls) {
- event.color = LorenzColor.GOLD.toColor().withAlpha(1)
- }
- }
-
- @SubscribeEvent
fun onWorldRender(event: LorenzRenderWorldEvent) {
if (!IslandType.THE_END.isInIsland()) return
@@ -170,11 +165,17 @@ class EndermanSlayerFeatures {
if (!IslandType.THE_END.isInIsland()) return
if (!event.repeatSeconds(1)) return
- nukekubiSkulls.also { skulls -> skulls.removeAll { it.isDead } }
- if (flyingBeacons.any { it.isDead }) {
- flyingBeacons = flyingBeacons.editCopy {
- removeAll { it.isDead }
+ nukekubiSkulls.removeAll {
+ if (it.isDead) {
+ RenderLivingEntityHelper.removeEntityColor(it)
}
+ it.isDead
+ }
+ flyingBeacons.removeAll {
+ if (it.isDead) {
+ RenderLivingEntityHelper.removeEntityColor(it)
+ }
+ it.isDead
}
// Removing the beacon if It's still there after 7 sesconds.
@@ -196,9 +197,8 @@ class EndermanSlayerFeatures {
if (event.new == "beacon") {
val armorStand = flyingBeacons.find { location.distance(it.getLorenzVec()) < 3 }
if (armorStand != null) {
- flyingBeacons = flyingBeacons.editCopy {
- remove(armorStand)
- }
+ flyingBeacons.remove(armorStand)
+ RenderLivingEntityHelper.removeEntityColor(armorStand)
sittingBeacon = sittingBeacon.editCopy { this[location] = SimpleTimeMark.now() }
logger.log("Replaced flying beacon with sitting beacon at $location")
}
@@ -213,7 +213,7 @@ class EndermanSlayerFeatures {
@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
endermenWithBeacons.clear()
- flyingBeacons = emptyList()
+ flyingBeacons.clear()
nukekubiSkulls.clear()
sittingBeacon = emptyMap()
logger.log("Reset everything (world change)")