From c14cfe950c8d0959e7c6b6fed7fd091b0cf826fe Mon Sep 17 00:00:00 2001 From: "Erymanthus[#5074] | (u/)RayDeeUx" <51521765+RayDeeUx@users.noreply.github.com> Date: Thu, 2 Nov 2023 19:04:20 -0400 Subject: Feature: The Great Spook Display Utilities and Notif Sound (#660) Added support for showing the primal fear data from tab list as gui elements and play warning sound when the next primal fear can spawn. #660 --- .../skyhanni/features/event/spook/TheGreatSpook.kt | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt (limited to 'src/main/java/at/hannibal2/skyhanni/features') diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt b/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt new file mode 100644 index 000000000..f0334549e --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt @@ -0,0 +1,58 @@ +package at.hannibal2.skyhanni.features.event.spook + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import at.hannibal2.skyhanni.utils.SoundUtils +import at.hannibal2.skyhanni.utils.TabListData +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class TheGreatSpook { +// §r§cPrimal Fears§r§7: §r§6§lREADY!! + private val config get() = SkyHanniMod.feature.event.spook + private var displayTimer = "" + private var displayFearStat = "" + private var displayTimeLeft = "" + private var notificationSeconds = 0 + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (isAllDisabled()) return + if (!event.repeatSeconds(1)) return + + if (isTimerEnabled() || isNotificationEnabled()) displayTimer = checkTabList(" §r§cPrimal Fears§r§7: ") + if (isFearStatEnabled()) displayFearStat = checkTabList(" §r§5Fear: ") + if (isTimeLeftEnabled()) displayTimeLeft = checkTabList(" §r§dEnds In§r§7: ") + if (isNotificationEnabled()) { + if (displayTimer.endsWith("READY!!")) { + if (notificationSeconds > 0) { + SoundUtils.playBeepSound() + notificationSeconds-- + } + } else if (displayTimer.isNotEmpty()) { + notificationSeconds = 5 + } + } + } + + private fun checkTabList(matchString: String): String { + return (TabListData.getTabList().find { it.contains(matchString) } ?: "").trim() + } + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { + if (isTimerEnabled()) config.positionTimer.renderString(displayTimer, posLabel = "Primal Fear Timer") + if (isFearStatEnabled()) config.positionFear.renderString(displayFearStat, posLabel = "Fear Stat Display") + if (isTimeLeftEnabled()) config.positionTimeLeft.renderString(displayTimeLeft, posLabel = "Time Left Display") + } + + private fun isTimerEnabled(): Boolean = LorenzUtils.inSkyBlock && config.primalFearTimer + + private fun isNotificationEnabled(): Boolean = LorenzUtils.inSkyBlock && config.primalFearNotification + private fun isFearStatEnabled(): Boolean = LorenzUtils.inSkyBlock && config.fearStatDisplay + private fun isTimeLeftEnabled(): Boolean = LorenzUtils.inSkyBlock && config.greatSpookTimeLeft + + private fun isAllDisabled(): Boolean = !isTimeLeftEnabled() && !isTimerEnabled() && !isFearStatEnabled() && + !isNotificationEnabled() +} -- cgit