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 --- .../com/ambientaddons/features/kuudra/KuudraHp.kt | 25 +++++++++++++++ .../ambientaddons/features/kuudra/KuudraReady.kt | 36 ++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 src/main/kotlin/com/ambientaddons/features/kuudra/KuudraHp.kt create mode 100644 src/main/kotlin/com/ambientaddons/features/kuudra/KuudraReady.kt (limited to 'src/main/kotlin/com/ambientaddons/features/kuudra') 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 -- cgit