diff options
author | Appability <appable@icloud.com> | 2022-11-01 10:53:35 -0700 |
---|---|---|
committer | Appability <appable@icloud.com> | 2022-11-01 10:53:35 -0700 |
commit | cd7b9b35164a7b2316745a91e21baa66ea2bc754 (patch) | |
tree | 988ee0030c89d9a8431e9d0573521041d17e0b96 | |
parent | 38e6266d2e608f376833dc9bc0c1074bed24535b (diff) | |
download | AmbientAddons-cd7b9b35164a7b2316745a91e21baa66ea2bc754.tar.gz AmbientAddons-cd7b9b35164a7b2316745a91e21baa66ea2bc754.tar.bz2 AmbientAddons-cd7b9b35164a7b2316745a91e21baa66ea2bc754.zip |
dropship alert
5 files changed, 68 insertions, 29 deletions
diff --git a/src/main/kotlin/com/ambientaddons/AmbientAddons.kt b/src/main/kotlin/com/ambientaddons/AmbientAddons.kt index 406cc41..d8faa8d 100644 --- a/src/main/kotlin/com/ambientaddons/AmbientAddons.kt +++ b/src/main/kotlin/com/ambientaddons/AmbientAddons.kt @@ -11,7 +11,7 @@ import com.ambientaddons.features.dungeon.terminals.MelodyHelper import com.ambientaddons.features.keybinds.PerspectiveKeybind import com.ambientaddons.features.keybinds.SendLastMessageKeybind import com.ambientaddons.features.kuudra.KuudraReady -import com.ambientaddons.features.kuudra.KuudraHp +import com.ambientaddons.features.kuudra.KuudraFeatures import com.ambientaddons.features.misc.* import com.ambientaddons.gui.GuiElement import com.ambientaddons.utils.SBLocation @@ -77,14 +77,13 @@ class AmbientAddons { CatOverlay, PingOverlay, ThornOverlay, - KuudraHp + KuudraFeatures ).forEach(MinecraftForge.EVENT_BUS::register) keyBinds.values.forEach(ClientRegistry::registerKeyBinding) guiElements = listOf( CatOverlay.element, PingOverlay.element, ThornOverlay.element, - KuudraHp.element ) } diff --git a/src/main/kotlin/com/ambientaddons/config/Config.kt b/src/main/kotlin/com/ambientaddons/config/Config.kt index 8c20b46..691b784 100644 --- a/src/main/kotlin/com/ambientaddons/config/Config.kt +++ b/src/main/kotlin/com/ambientaddons/config/Config.kt @@ -14,6 +14,7 @@ object Config : Vigilant( var kuudraReady = false var kuudraHp = false + var kuudraAlert = false var autoTrapper = false var trapperEsp = false @@ -64,6 +65,11 @@ object Config : Vigilant( name = "Show Kuudra health", description = "Shows Kuudra health percentage in boss bar.", ) + switch( + ::kuudraAlert, + name = "Kuudra dropship alert", + description = "Shows an alert when a dropship is approaching.", + ) } subcategory("Trevor the Trapper") { switch( diff --git a/src/main/kotlin/com/ambientaddons/features/kuudra/KuudraFeatures.kt b/src/main/kotlin/com/ambientaddons/features/kuudra/KuudraFeatures.kt new file mode 100644 index 0000000..5ca8d1e --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/features/kuudra/KuudraFeatures.kt @@ -0,0 +1,58 @@ +package com.ambientaddons.features.kuudra + +import AmbientAddons.Companion.config +import AmbientAddons.Companion.mc +import com.ambientaddons.events.BossStatusEvent +import com.ambientaddons.utils.Area +import com.ambientaddons.utils.Extensions.stripControlCodes +import com.ambientaddons.utils.SBLocation +import net.minecraft.entity.boss.BossStatus +import net.minecraft.entity.monster.EntityGhast +import net.minecraft.util.Vec3 +import net.minecraftforge.client.event.RenderWorldLastEvent +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object KuudraFeatures { + private val dropships = mutableSetOf<EntityGhast>() + + private fun colorizeHealth(healthFraction: Float) = when { + healthFraction > 0.75F -> "§a" + healthFraction > 0.50F -> "§e" + healthFraction > 0.25F -> "§6" + else -> "§e" + } + + @SubscribeEvent + fun onBossBarSet(event: BossStatusEvent) { + if (!config.kuudraHp || SBLocation.area != Area.Kuudra) return + val bossData = event.displayData + if (bossData.displayName.unformattedText.stripControlCodes().contains("Kuudra")) { + val healthFraction = bossData.health / bossData.maxHealth + BossStatus.healthScale = healthFraction + BossStatus.statusBarTime = 100 + val percentString = String.format("%.1f", healthFraction * 100) + BossStatus.bossName = + "${bossData.displayName.formattedText} §r§8 - §r${colorizeHealth(healthFraction)} ${percentString}%" + event.isCanceled = true + } + } + + @SubscribeEvent + fun onWorldUnload(event: WorldEvent.Unload) { + dropships.clear() + } + + @SubscribeEvent + fun onRenderWorldLast(event: RenderWorldLastEvent) { + if (!config.kuudraAlert || SBLocation.area != Area.Kuudra) return + mc.theWorld.loadedEntityList.forEach { + if (it !is EntityGhast || dropships.contains(it)) return@forEach + if (it.positionVector.squareDistanceTo(Vec3(-101.0, 100.0, -106.0)) < 225) { + mc.ingameGUI.displayTitle("§cDropship!", null, 5, 40, 5) + mc.thePlayer.playSound("random.orb", 1f, 0.5f) + dropships.add(it) + } + } + } +}
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/features/kuudra/KuudraHp.kt b/src/main/kotlin/com/ambientaddons/features/kuudra/KuudraHp.kt deleted file mode 100644 index 79f6428..0000000 --- a/src/main/kotlin/com/ambientaddons/features/kuudra/KuudraHp.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.ambientaddons.features.kuudra - -import AmbientAddons.Companion.config -import com.ambientaddons.events.BossStatusEvent -import com.ambientaddons.gui.GuiElement -import com.ambientaddons.utils.Area -import com.ambientaddons.utils.Extensions.stripControlCodes -import com.ambientaddons.utils.SBLocation -import net.minecraft.entity.boss.BossStatus -import net.minecraftforge.client.event.ClientChatReceivedEvent -import net.minecraftforge.client.event.RenderGameOverlayEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -object KuudraHp { - - fun onBossBarSet(event: BossStatusEvent) { - if (!config.kuudraHp || SBLocation.area != Area.Kuudra) return - val bossData = event.displayData - if (bossData.displayName.unformattedText.stripControlCodes().contains("Kuudra")) { - BossStatus.healthScale = bossData.health / bossData.maxHealth - BossStatus.statusBarTime = 100 - BossStatus.bossName = "${bossData.displayName.formattedText} §r§8 - §r§d ${S}" - } - } -}
\ No newline at end of file diff --git a/src/main/resources/mixins.ambientaddons.json b/src/main/resources/mixins.ambientaddons.json index ca3aa8e..68a778c 100644 --- a/src/main/resources/mixins.ambientaddons.json +++ b/src/main/resources/mixins.ambientaddons.json @@ -9,6 +9,7 @@ "MixinGuiContainer", "MixinNetworkManager", "MixinRenderItem", - "MixinGuiScreen" + "MixinGuiScreen", + "MixinBossStatus" ] } |