diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-02 20:38:55 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-02 20:38:55 +0100 |
commit | ee0ae23560e911fbec5e5262feaaa58dc5d52e7a (patch) | |
tree | ecd2221d199c8768aae9442c4c81922b0e0352f1 /src/main/java/at/hannibal2/skyhanni/features | |
parent | 6173d681603839168db97e3fbd2cb74c2e7a2897 (diff) | |
download | skyhanni-ee0ae23560e911fbec5e5262feaaa58dc5d52e7a.tar.gz skyhanni-ee0ae23560e911fbec5e5262feaaa58dc5d52e7a.tar.bz2 skyhanni-ee0ae23560e911fbec5e5262feaaa58dc5d52e7a.zip |
Created EntityMaxHealthUpdateEvent, started with better logic for colored mobs.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
7 files changed, 95 insertions, 212 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/end/VoidlingExtremistColor.kt b/src/main/java/at/hannibal2/skyhanni/features/end/VoidlingExtremistColor.kt deleted file mode 100644 index c9b02bf5d..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/end/VoidlingExtremistColor.kt +++ /dev/null @@ -1,59 +0,0 @@ -package at.hannibal2.skyhanni.features.end - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.events.RenderMobColoredEvent -import at.hannibal2.skyhanni.events.ResetEntityHurtEvent -import at.hannibal2.skyhanni.events.withAlpha -import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth -import at.hannibal2.skyhanni.utils.LorenzColor -import at.hannibal2.skyhanni.utils.LorenzUtils -import net.minecraft.client.Minecraft -import net.minecraft.entity.monster.EntityEnderman -import net.minecraftforge.event.world.WorldEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent - -class VoidlingExtremistColor { - - private var tick = 0 - private val extremists = mutableListOf<EntityEnderman>() - - @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (!isEnabled()) return - - if (tick++ % 60 == 0) { - Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityEnderman>() - .filter { it !in extremists && it.hasMaxHealth(8_000_000) }.forEach { extremists.add(it) } - } - } - - @SubscribeEvent - fun onRenderMobColored(event: RenderMobColoredEvent) { - if (!isEnabled()) return - val entity = event.entity - - if (entity in extremists) { - event.color = LorenzColor.LIGHT_PURPLE.toColor().withAlpha(127) - } - } - - @SubscribeEvent - fun onResetEntityHurtTime(event: ResetEntityHurtEvent) { - if (!isEnabled()) return - val entity = event.entity - - if (entity in extremists) { - event.shouldReset = true - } - } - - @SubscribeEvent - fun onWorldChange(event: WorldEvent.Load) { - extremists.clear() - } - - private fun isEnabled(): Boolean = - LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.THE_END && SkyHanniMod.feature.misc.voidlingExtremistColor -}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CorruptedMobHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CorruptedMobHighlight.kt index 0b4effca4..898a18b3d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CorruptedMobHighlight.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CorruptedMobHighlight.kt @@ -24,7 +24,7 @@ class CorruptedMobHighlight { val entity = event.entity if (entity in corruptedMobs) return - val baseMaxHealth = entity.baseMaxHealth.toFloat() + val baseMaxHealth = entity.baseMaxHealth if (event.health == baseMaxHealth * 3) { corruptedMobs.add(entity) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/HighlightAreaMiniBoss.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/HighlightAreaMiniBoss.kt new file mode 100644 index 000000000..66e6ceca3 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/HighlightAreaMiniBoss.kt @@ -0,0 +1,40 @@ +package at.hannibal2.skyhanni.features.misc + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent +import at.hannibal2.skyhanni.events.withAlpha +import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.entity.monster.EntityBlaze +import net.minecraft.entity.monster.EntityEnderman +import net.minecraft.entity.monster.EntityMob +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class HighlightAreaMiniBoss { + + @SubscribeEvent + fun onEntityHealthUpdate(event: EntityMaxHealthUpdateEvent) { + if (!isEnabled()) return + + for (bossType in AreaMiniBossType.values()) { + val clazz = bossType.clazz + val entity = event.entity + + if (!clazz.isInstance(entity)) continue + if (event.maxHealth != bossType.health) continue + + RenderLivingEntityHelper.setEntityColor(entity, bossType.color) + RenderLivingEntityHelper.setNoHurtTime(entity) + } + } + + private fun isEnabled(): Boolean = + LorenzUtils.inSkyBlock && SkyHanniMod.feature.misc.highlightAreaMinisBoss + + enum class AreaMiniBossType(val clazz: Class<out EntityMob>, val health: Int, val color: Int) { + ENDERMAN(EntityEnderman::class.java, 8_000_000, LorenzColor.LIGHT_PURPLE.toColor().withAlpha(127)), + BLAZE(EntityBlaze::class.java, 30_000_000, LorenzColor.DARK_RED.toColor().withAlpha(60)), + ; + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/MilleniaAgedBlazeColor.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/MilleniaAgedBlazeColor.kt deleted file mode 100644 index 8a9cad4fa..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/MilleniaAgedBlazeColor.kt +++ /dev/null @@ -1,59 +0,0 @@ -package at.hannibal2.skyhanni.features.nether - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.events.RenderMobColoredEvent -import at.hannibal2.skyhanni.events.ResetEntityHurtEvent -import at.hannibal2.skyhanni.events.withAlpha -import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth -import at.hannibal2.skyhanni.utils.LorenzColor -import at.hannibal2.skyhanni.utils.LorenzUtils -import net.minecraft.client.Minecraft -import net.minecraft.entity.monster.EntityBlaze -import net.minecraftforge.event.world.WorldEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent - -class MilleniaAgedBlazeColor { - - private var tick = 0 - private val blazes = mutableListOf<EntityBlaze>() - - @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (!isEnabled()) return - - if (tick++ % 60 == 0) { - Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityBlaze>() - .filter { it !in blazes && it.hasMaxHealth(30_000_000) }.forEach { blazes.add(it) } - } - } - - @SubscribeEvent - fun onRenderMobColored(event: RenderMobColoredEvent) { - if (!isEnabled()) return - val entity = event.entity - - if (entity in blazes) { - event.color = LorenzColor.DARK_RED.toColor().withAlpha(60) - } - } - - @SubscribeEvent - fun onResetEntityHurtTime(event: ResetEntityHurtEvent) { - if (!isEnabled()) return - val entity = event.entity - - if (entity in blazes) { - event.shouldReset = true - } - } - - @SubscribeEvent - fun onWorldChange(event: WorldEvent.Load) { - blazes.clear() - } - - private fun isEnabled() = - LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.CRIMSON_ISLE && SkyHanniMod.feature.misc.milleniaAgedBlazeColor -}
\ No newline at end of file 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 ef3f965a1..4e9382d8f 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 @@ -64,7 +64,7 @@ class AshfangBlazes { val entityId = event.entity.entityId if (entityId !in blazeArmorStand.keys.map { it.entityId }) return - if (event.health % 10_000_000 != 0F) { + if (event.health % 10_000_000 != 0) { blazeArmorStand.keys.removeIf { it.entityId == entityId } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt new file mode 100644 index 000000000..9542efa93 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt @@ -0,0 +1,53 @@ +package at.hannibal2.skyhanni.features.slayer + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent +import at.hannibal2.skyhanni.events.withAlpha +import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.entity.EntityCreature +import net.minecraft.entity.monster.EntityBlaze +import net.minecraft.entity.monster.EntityEnderman +import net.minecraft.entity.monster.EntitySpider +import net.minecraft.entity.monster.EntityZombie +import net.minecraft.entity.passive.EntityWolf +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class HighlightSlayerMiniBoss { + + @SubscribeEvent + fun onEntityHealthUpdate(event: EntityMaxHealthUpdateEvent) { + if (!isEnabled()) return + + val entity = event.entity + + if (DamageIndicatorManager.isBoss(entity)) return + + val maxHealth = event.maxHealth + + for (bossType in AreaMiniBossType.values()) { + if (!bossType.clazz.isInstance(entity)) continue + + if (bossType.health.any { entity.hasMaxHealth(it, false, maxHealth) }) { + RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.AQUA.toColor().withAlpha(127)) + RenderLivingEntityHelper.setNoHurtTime(entity) + } + } + } + + private fun isEnabled(): Boolean { + return LorenzUtils.inSkyBlock && SkyHanniMod.feature.slayer.slayerMinibossHighlight && !LorenzUtils.inDungeons && !LorenzUtils.inKuudraFight + } + + enum class AreaMiniBossType(val clazz: Class<out EntityCreature>, vararg val health: Int) { + REVENANT(EntityZombie::class.java, 24_000, 90_000, 360_000, 600_000, 2_400_000), + TARANTULA(EntitySpider::class.java, 54_000, 144_000, 576_000), + SVEN(EntityWolf::class.java, 45_000, 120_000, 450_000), + VOIDLING(EntityEnderman::class.java, 8_400_000, 17_500_000, 52_500_000), + INFERNAL(EntityBlaze::class.java, 12_000_000, 25_000_000), + ; + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniboss.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniboss.kt deleted file mode 100644 index abbb2a315..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniboss.kt +++ /dev/null @@ -1,92 +0,0 @@ -package at.hannibal2.skyhanni.features.slayer - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.RenderMobColoredEvent -import at.hannibal2.skyhanni.events.ResetEntityHurtEvent -import at.hannibal2.skyhanni.events.withAlpha -import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager -import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth -import at.hannibal2.skyhanni.utils.LorenzColor -import at.hannibal2.skyhanni.utils.LorenzUtils -import net.minecraft.client.Minecraft -import net.minecraft.entity.EntityLivingBase -import net.minecraft.entity.monster.EntityBlaze -import net.minecraft.entity.monster.EntityEnderman -import net.minecraft.entity.monster.EntitySpider -import net.minecraft.entity.monster.EntityZombie -import net.minecraft.entity.passive.EntityWolf -import net.minecraftforge.event.world.WorldEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent - -class HighlightSlayerMiniboss { - - private var tick = 0 - private val miniBosses = mutableListOf<EntityLivingBase>() - - @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (!isEnabled()) return - - if (tick++ % 20 == 0) { - find() - } - } - - private fun find() { - val entityList = Minecraft.getMinecraft().theWorld.loadedEntityList - val list = mutableListOf<EntityLivingBase>() - - list.addAll(entityList.filterIsInstance<EntityZombie>().filter { - it.hasMaxHealth(24_000) || it.hasMaxHealth(90_000) || it.hasMaxHealth(360_000) || it.hasMaxHealth(600_000) || it.hasMaxHealth(2_400_000) - }) - - list.addAll(entityList.filterIsInstance<EntitySpider>().filter { - it.hasMaxHealth(54_000) || it.hasMaxHealth(144_000) || it.hasMaxHealth(576_000) - }) - - list.addAll(entityList.filterIsInstance<EntityWolf>().filter { - it.hasMaxHealth(45_000) || it.hasMaxHealth(120_000) || it.hasMaxHealth(450_000) - }) - - list.addAll(entityList.filterIsInstance<EntityEnderman>().filter { - it.hasMaxHealth(12_000_000) || it.hasMaxHealth(17_500_000) || it.hasMaxHealth(52_500_000) - }) - - list.addAll(entityList.filterIsInstance<EntityBlaze>().filter { - it.hasMaxHealth(12_000_000) || it.hasMaxHealth(25_000_000) - }) - - list.filter { it !in miniBosses && !DamageIndicatorManager.isBoss(it) }.forEach(miniBosses::add) - miniBosses.removeIf { DamageIndicatorManager.isBoss(it) } - } - - @SubscribeEvent - fun onRenderMobColored(event: RenderMobColoredEvent) { - if (!isEnabled()) return - val entity = event.entity - - if (entity in miniBosses) { - event.color = LorenzColor.AQUA.toColor().withAlpha(127) - } - } - - @SubscribeEvent - fun onResetEntityHurtTime(event: ResetEntityHurtEvent) { - if (!isEnabled()) return - val entity = event.entity - - if (entity in miniBosses) { - event.shouldReset = true - } - } - - @SubscribeEvent - fun onWorldChange(event: WorldEvent.Load) { - miniBosses.clear() - } - - private fun isEnabled(): Boolean { - return LorenzUtils.inSkyBlock && SkyHanniMod.feature.slayer.slayerMinibossHighlight && !LorenzUtils.inDungeons && !LorenzUtils.inKuudraFight - } -} |