From 38e6266d2e608f376833dc9bc0c1074bed24535b Mon Sep 17 00:00:00 2001 From: Appability Date: Sun, 30 Oct 2022 20:42:56 -0700 Subject: kuudra HP display features --- src/main/kotlin/com/ambientaddons/AmbientAddons.kt | 8 +++-- src/main/kotlin/com/ambientaddons/config/Config.kt | 6 ++++ .../com/ambientaddons/events/BossStatusEvent.kt | 8 +++++ .../com/ambientaddons/features/kuudra/KuudraHp.kt | 25 +++++++++++++++ .../ambientaddons/features/kuudra/KuudraReady.kt | 36 ++++++++++++++++++++++ .../com/ambientaddons/features/misc/BonzoMask.kt | 2 +- .../com/ambientaddons/features/misc/KuudraReady.kt | 36 ---------------------- src/main/kotlin/com/ambientaddons/utils/Timer.kt | 30 ++++++++++++++++++ 8 files changed, 112 insertions(+), 39 deletions(-) create mode 100644 src/main/kotlin/com/ambientaddons/events/BossStatusEvent.kt create mode 100644 src/main/kotlin/com/ambientaddons/features/kuudra/KuudraHp.kt create mode 100644 src/main/kotlin/com/ambientaddons/features/kuudra/KuudraReady.kt delete mode 100644 src/main/kotlin/com/ambientaddons/features/misc/KuudraReady.kt create mode 100644 src/main/kotlin/com/ambientaddons/utils/Timer.kt (limited to 'src/main/kotlin') diff --git a/src/main/kotlin/com/ambientaddons/AmbientAddons.kt b/src/main/kotlin/com/ambientaddons/AmbientAddons.kt index 57ded8a..406cc41 100644 --- a/src/main/kotlin/com/ambientaddons/AmbientAddons.kt +++ b/src/main/kotlin/com/ambientaddons/AmbientAddons.kt @@ -10,6 +10,8 @@ import com.ambientaddons.features.dungeon.* 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.misc.* import com.ambientaddons.gui.GuiElement import com.ambientaddons.utils.SBLocation @@ -74,13 +76,15 @@ class AmbientAddons { CrimsonFishing, CatOverlay, PingOverlay, - ThornOverlay + ThornOverlay, + KuudraHp ).forEach(MinecraftForge.EVENT_BUS::register) keyBinds.values.forEach(ClientRegistry::registerKeyBinding) guiElements = listOf( CatOverlay.element, PingOverlay.element, - ThornOverlay.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 753d401..8c20b46 100644 --- a/src/main/kotlin/com/ambientaddons/config/Config.kt +++ b/src/main/kotlin/com/ambientaddons/config/Config.kt @@ -13,6 +13,7 @@ object Config : Vigilant( var kuudraReady = false + var kuudraHp = false var autoTrapper = false var trapperEsp = false @@ -58,6 +59,11 @@ object Config : Vigilant( name = "Automatically ready in Kuudra", description = "Automatically clicks the ready pane when the ready GUI is opened." ) + switch( + ::kuudraHp, + name = "Show Kuudra health", + description = "Shows Kuudra health percentage in boss bar.", + ) } subcategory("Trevor the Trapper") { switch( diff --git a/src/main/kotlin/com/ambientaddons/events/BossStatusEvent.kt b/src/main/kotlin/com/ambientaddons/events/BossStatusEvent.kt new file mode 100644 index 0000000..cefd993 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/events/BossStatusEvent.kt @@ -0,0 +1,8 @@ +package com.ambientaddons.events + +import net.minecraft.entity.boss.IBossDisplayData +import net.minecraftforge.fml.common.eventhandler.Cancelable +import net.minecraftforge.fml.common.eventhandler.Event + +@Cancelable +class BossStatusEvent(val displayData: IBossDisplayData, val hasColorModifierIn: Boolean) : Event() \ 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 new file mode 100644 index 0000000..79f6428 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/features/kuudra/KuudraHp.kt @@ -0,0 +1,25 @@ +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/kotlin/com/ambientaddons/features/kuudra/KuudraReady.kt b/src/main/kotlin/com/ambientaddons/features/kuudra/KuudraReady.kt new file mode 100644 index 0000000..8133182 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/features/kuudra/KuudraReady.kt @@ -0,0 +1,36 @@ +package com.ambientaddons.features.kuudra + +import AmbientAddons.Companion.config +import AmbientAddons.Companion.mc +import com.ambientaddons.utils.Area +import com.ambientaddons.utils.Extensions.chest +import com.ambientaddons.utils.Extensions.items +import com.ambientaddons.utils.Extensions.lore +import com.ambientaddons.utils.Extensions.stripControlCodes +import com.ambientaddons.utils.SBLocation +import net.minecraftforge.client.event.GuiScreenEvent +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object KuudraReady { + private var hasClickedReady = false + + @SubscribeEvent + fun onWorldUnload(event: WorldEvent.Unload) { + hasClickedReady = false + } + + @SubscribeEvent + fun onGuiDraw(event: GuiScreenEvent.DrawScreenEvent) { + if (!config.kuudraReady || SBLocation.area != Area.Kuudra) return + val chest = event.gui?.chest ?: return + val chestName = chest.lowerChestInventory.name + if (chestName == "Ready Up" && !hasClickedReady) { + val clickIndex = chest.lowerChestInventory.items.takeIf { it.last() != null }?.indexOfFirst { + it?.lore?.getOrNull(0)?.stripControlCodes()?.startsWith("Click to mark yourself") == true + } ?: return + hasClickedReady = true + mc.playerController.windowClick(chest.windowId, clickIndex, 2, 3, mc.thePlayer) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt b/src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt index 2e8be9e..022a435 100644 --- a/src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt +++ b/src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt @@ -38,7 +38,7 @@ object BonzoMask { else -> false } if (config.maskWarning && didMaskProc) { - mc.ingameGUI.displayTitle("§cMask!", null, 5, 20, 5) + mc.ingameGUI.displayTitle("§cMask!", null, 5, 40, 5) } } diff --git a/src/main/kotlin/com/ambientaddons/features/misc/KuudraReady.kt b/src/main/kotlin/com/ambientaddons/features/misc/KuudraReady.kt deleted file mode 100644 index d9be1dd..0000000 --- a/src/main/kotlin/com/ambientaddons/features/misc/KuudraReady.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.ambientaddons.features.misc - -import AmbientAddons.Companion.config -import AmbientAddons.Companion.mc -import com.ambientaddons.utils.Area -import com.ambientaddons.utils.Extensions.chest -import com.ambientaddons.utils.Extensions.items -import com.ambientaddons.utils.Extensions.lore -import com.ambientaddons.utils.Extensions.stripControlCodes -import com.ambientaddons.utils.SBLocation -import net.minecraftforge.client.event.GuiScreenEvent -import net.minecraftforge.event.world.WorldEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -object KuudraReady { - private var hasClickedReady = false - - @SubscribeEvent - fun onWorldUnload(event: WorldEvent.Unload) { - hasClickedReady = false - } - - @SubscribeEvent - fun onGuiDraw(event: GuiScreenEvent.DrawScreenEvent) { - if (!config.kuudraReady || SBLocation.area != Area.Kuudra) return - val chest = event.gui?.chest ?: return - val chestName = chest.lowerChestInventory.name - if (chestName == "Ready Up" && !hasClickedReady) { - val clickIndex = chest.lowerChestInventory.items.takeIf { it.last() != null }?.indexOfFirst { - it?.lore?.getOrNull(0)?.stripControlCodes()?.startsWith("Click to mark yourself") == true - } ?: return - hasClickedReady = true - mc.playerController.windowClick(chest.windowId, clickIndex, 2, 3, mc.thePlayer) - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/utils/Timer.kt b/src/main/kotlin/com/ambientaddons/utils/Timer.kt new file mode 100644 index 0000000..dab30b2 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/utils/Timer.kt @@ -0,0 +1,30 @@ +package com.ambientaddons.utils + +class Timer { + private var previousTime: Long = 0 + private var startTime: Long? = null + + var isRunning: Boolean = false + private set + + private val sessionTime: Long + get() { + return startTime?.let { System.currentTimeMillis() - it } ?: 0 + } + + private val time: Long + get() { + return sessionTime?.let { it + previousTime } ?: 0 + } + + fun start() { + isRunning = true + startTime = System.currentTimeMillis() + } + + fun stop() { + isRunning = false + previousTime = sessionTime + startTime = null + } +} \ No newline at end of file -- cgit