diff options
author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-08-26 10:27:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-26 10:27:32 +0200 |
commit | d13954de4de5d9a04380bb4105c13d7ae564255e (patch) | |
tree | b9ad05a6de3523231ed6ea5ff0259a7cc66497c3 /src/main/java/at/hannibal2/skyhanni/features | |
parent | 57224a6c4c4dac2eba2892f29ab4f41cee435995 (diff) | |
download | skyhanni-d13954de4de5d9a04380bb4105c13d7ae564255e.tar.gz skyhanni-d13954de4de5d9a04380bb4105c13d7ae564255e.tar.bz2 skyhanni-d13954de4de5d9a04380bb4105c13d7ae564255e.zip |
Feature: Starred Mob Highlight + Fels Highlight/Line (#1558)
Co-authored-by: Cal <cwolfson58@gmail.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMobManager.kt | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMobManager.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMobManager.kt new file mode 100644 index 000000000..46450a564 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMobManager.kt @@ -0,0 +1,149 @@ +package at.hannibal2.skyhanni.features.dungeon + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.data.mob.Mob +import at.hannibal2.skyhanni.data.mob.MobData +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.MobEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor +import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine +import at.hannibal2.skyhanni.utils.RenderUtils.drawWaypointFilled +import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation +import at.hannibal2.skyhanni.utils.getLorenzVec +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.awt.Color + +@SkyHanniModule +object DungeonMobManager { + + private val config get() = SkyHanniMod.feature.dungeon.objectHighlighter + private val starredConfig get() = config.starred + private val fel get() = config.fel + + private val staredInvisible = mutableSetOf<Mob>() + private val felOnTheGround = mutableSetOf<Mob>() + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + onToggle( + starredConfig.highlight, + starredConfig.colour, + ) { + val color = if (starredConfig.highlight.get()) getStarColor() else null + MobData.skyblockMobs.filter { it.hasStar }.forEach { + handleStar0(it, color) + } + if (!starredConfig.highlight.get()) { + staredInvisible.clear() + } + } + onToggle( + fel.highlight, + fel.colour, + ) { + if (fel.highlight.get()) { + if (felOnTheGround.isEmpty()) { + MobData.skyblockMobs.forEach(::handleFel) + } + } else { + felOnTheGround.clear() + } + } + } + + @SubscribeEvent + fun onMobSpawn(event: MobEvent.Spawn.SkyblockMob) { + if (event.mob.mobType != Mob.Type.DUNGEON) return + handleStar(event.mob) + handleFel(event.mob) + } + + @SubscribeEvent + fun onMobDeSpawn(event: MobEvent.DeSpawn.SkyblockMob) { + if (event.mob.mobType != Mob.Type.DUNGEON) return + if (starredConfig.highlight.get()) { + staredInvisible.remove(event.mob) + } + handleFelDespawn(event.mob) + } + + @SubscribeEvent + fun onLorenzTick(event: LorenzTickEvent) { + if (!IslandType.CATACOMBS.isInIsland()) return + handleInvisibleStar() + } + + @SubscribeEvent + fun onRenderWorld(event: LorenzRenderWorldEvent) { + if (!fel.highlight.get()) return + if (fel.line) { + felOnTheGround.filter { it.canBeSeen() }.forEach { + event.draw3DLine( + it.baseEntity.getLorenzVec().add(y = 0.15), + event.exactPlayerEyeLocation(), + fel.colour.get().toChromaColor(), + 3, + true, + ) + } + } + + felOnTheGround.removeIf { mob -> + event.drawWaypointFilled( + mob.baseEntity.getLorenzVec().add(-0.5, -0.23, -0.5), + fel.colour.get().toChromaColor(), + seeThroughBlocks = false, + beacon = false, + extraSize = -0.2, + minimumAlpha = 0.8f, + inverseAlphaScale = true, + ) + !mob.isInvisible() + } + } + + private fun handleStar(mob: Mob) { + if (!starredConfig.highlight.get()) return + if (!mob.hasStar) return + handleStar0(mob, getStarColor()) + } + + private fun handleInvisibleStar() { + if (!starredConfig.highlight.get()) return + staredInvisible.removeIf { + val visible = !it.isInvisible() + if (visible) { + it.highlight(getStarColor()) + } + visible + } + } + + private fun getStarColor(): Color = starredConfig.colour.get().toChromaColor() + + private fun handleStar0(mob: Mob, colour: Color?) { + if (mob.isInvisible()) { + staredInvisible.add(mob) + return + } + mob.highlight(colour) + } + + private fun handleFel(mob: Mob) { + if (!fel.highlight.get()) return + if (mob.name != "Fels") return + if (!mob.isInvisible()) return + felOnTheGround.add(mob) + } + + private fun handleFelDespawn(mob: Mob) { + if (!fel.highlight.get()) return + felOnTheGround.remove(mob) + } +} |