diff options
Diffstat (limited to 'src/main/java/at')
5 files changed, 88 insertions, 55 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 1efe4dab9..f5e6f57a8 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -228,7 +228,7 @@ class SkyHanniMod { loadModule(AreaMiniBossFeatures()) loadModule(MobHighlight()) loadModule(MarkedPlayerManager()) - loadModule(HighlightSlayerMiniBoss()) + loadModule(SlayerMiniBossFeatures()) loadModule(PlayerDeathMessages()) loadModule(HighlightDungeonDeathmite()) loadModule(DungeonHideItems()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/SlayerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/SlayerConfig.java index b3678464c..d6af72b41 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/SlayerConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/SlayerConfig.java @@ -496,6 +496,12 @@ public class SlayerConfig { public boolean slayerMinibossHighlight = false; @Expose + @ConfigOption(name = "Line to Miniboss", desc = "Adds a line to every slayer miniboss around you.") + @ConfigEditorBoolean + @FeatureToggle + public boolean slayerMinibossLine = false; + + @Expose @ConfigOption(name = "Hide Mob Names", desc = "Hide the name of the mobs you need to kill in order for the Slayer boss to spawn. Exclude mobs that are damaged, corrupted, runic or semi rare.") @ConfigEditorBoolean @FeatureToggle 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 8c6399dde..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt +++ /dev/null @@ -1,52 +0,0 @@ -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 SlayerMiniBossType.entries) { - if (!bossType.clazz.isInstance(entity)) continue - - if (bossType.health.any { entity.hasMaxHealth(it, false, maxHealth) }) { - RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.AQUA.toColor().withAlpha(127)) - { SkyHanniMod.feature.slayer.slayerMinibossHighlight } - RenderLivingEntityHelper.setNoHurtTime(entity) { SkyHanniMod.feature.slayer.slayerMinibossHighlight } - } - } - } - - private fun isEnabled() = LorenzUtils.inSkyBlock && - SkyHanniMod.feature.slayer.slayerMinibossHighlight && - !LorenzUtils.inDungeons && !LorenzUtils.inKuudraFight - - enum class SlayerMiniBossType(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, 480_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/SlayerMiniBossFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerMiniBossFeatures.kt new file mode 100644 index 000000000..e25ac37eb --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerMiniBossFeatures.kt @@ -0,0 +1,80 @@ +package at.hannibal2.skyhanni.features.slayer + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +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.LocationUtils.distanceToPlayer +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy +import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine +import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation +import at.hannibal2.skyhanni.utils.getLorenzVec +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.client.event.RenderWorldLastEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class SlayerMiniBossFeatures { + private val config get() = SkyHanniMod.feature.slayer + private var miniBosses = listOf<EntityCreature>() + + @SubscribeEvent + fun onEntityHealthUpdate(event: EntityMaxHealthUpdateEvent) { + if (!isEnabled()) return + val entity = event.entity as? EntityCreature ?: return + if (DamageIndicatorManager.isBoss(entity)) return + + val maxHealth = event.maxHealth + for (bossType in SlayerMiniBossType.entries) { + if (!bossType.health.any { entity.hasMaxHealth(it, false, maxHealth) }) continue + if (!bossType.clazz.isInstance(entity)) continue + + miniBosses = miniBosses.editCopy { add(entity) } + RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.AQUA.toColor().withAlpha(127)) + { config.slayerMinibossHighlight } + RenderLivingEntityHelper.setNoHurtTime(entity) { config.slayerMinibossHighlight } + } + } + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + miniBosses = emptyList() + } + + @SubscribeEvent + fun onWorldRender(event: RenderWorldLastEvent) { + if (!config.slayerMinibossLine) return + for (mob in miniBosses) { + if (mob.isDead) continue + if (mob.distanceToPlayer() > 10) continue + + event.draw3DLine( + event.exactPlayerEyeLocation(), + mob.getLorenzVec().add(0, 1, 0), + LorenzColor.AQUA.toColor(), + 3, + true + ) + } + } + + private fun isEnabled() = LorenzUtils.inSkyBlock && !LorenzUtils.inDungeons && !LorenzUtils.inKuudraFight + + enum class SlayerMiniBossType(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, 480_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/enderman/EndermanSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt index b534945af..1264c14dc 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 @@ -23,7 +23,6 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.monster.EntityEnderman import net.minecraft.init.Blocks import net.minecraftforge.client.event.RenderWorldLastEvent -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds @@ -94,7 +93,7 @@ class EndermanSlayerFeatures { } } - @SubscribeEvent(priority = EventPriority.HIGH) + @SubscribeEvent fun onWorldRender(event: RenderWorldLastEvent) { if (!IslandType.THE_END.isInIsland()) return |