From 6b0e324c96073d824c12dff1629a782352155e99 Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Thu, 30 May 2024 11:21:50 +0200 Subject: Feature: Hotm Features + Hotm API/Data (#1059) Co-authored-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Co-authored-by: Empa <42304516+ItsEmpa@users.noreply.github.com> Co-authored-by: martimavocado <39881008+martimavocado@users.noreply.github.com> Co-authored-by: martimavocado Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../gui/customscoreboard/ScoreboardPattern.kt | 11 ++++- .../skyhanni/features/mining/HotmFeatures.kt | 53 ++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/mining/HotmFeatures.kt (limited to 'src/main/java/at/hannibal2/skyhanni/features') diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt index ec4cf0c6f..2db0c37f7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt @@ -173,9 +173,18 @@ object ScoreboardPattern { // mining private val miningSb = scoreboardGroup.group("mining") + + /** + * REGEX-TEST: §2᠅ §fMithril§f: §235,448 + * REGEX-TEST: §d᠅ §fGemstone§f: §d36,758 + * REGEX-TEST: §b᠅ §fGlacite§f: §b29,537 + * REGEX-TEST: §2᠅ §fMithril Powder§f: §235,448 + * REGEX-TEST: §d᠅ §fGemstone Powder§f: §d36,758 + * REGEX-TEST: §b᠅ §fGlacite Powder§f: §b29,537 + */ val powderPattern by miningSb.pattern( "powder", - "(§.)*᠅ §.(Gemstone|Mithril|Glacite)( Powder)?(§.)*:?.*$" + "(?:§.)*᠅ (?:§.)(?Gemstone|Mithril|Glacite)(?: Powder)?(?:§.)*:? (?:§.)*(?[\\d,.]*)" ) val windCompassPattern by miningSb.pattern( "windcompass", diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/HotmFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/HotmFeatures.kt new file mode 100644 index 000000000..c594312a3 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/HotmFeatures.kt @@ -0,0 +1,53 @@ +package at.hannibal2.skyhanni.features.mining + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.HotmData +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.RenderItemTipEvent +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class HotmFeatures { + + val config get() = SkyHanniMod.feature.mining.hotm + + fun isEnabled() = LorenzUtils.inSkyBlock && HotmData.inInventory + + @SubscribeEvent + fun onRender(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!isEnabled()) return + if (!config.highlightEnabledPerks) return + HotmData.entries.forEach { entry -> + val color = if (!entry.isUnlocked) LorenzColor.DARK_GRAY + else if (entry.enabled) LorenzColor.GREEN else LorenzColor.RED + entry.slot?.highlight(color) + } + } + + @SubscribeEvent + fun onRenderTip(event: RenderItemTipEvent) { + if (!isEnabled()) return + handleLevelStackSize(event) + handleTokenStackSize(event) + } + + private fun handleLevelStackSize(event: RenderItemTipEvent) { + if (!config.levelStackSize) return + HotmData.entries.firstOrNull() { + event.stack == it.slot?.stack + }?.let { + event.stackTip = if (it.activeLevel == 0 || it.activeLevel == it.maxLevel) "" else + "§e${it.activeLevel}" + it.activeLevel.toString() + } + } + + private fun handleTokenStackSize(event: RenderItemTipEvent) { + if (!config.tokenStackSize) return + if (event.stack != HotmData.heartItem?.stack) return + event.stackTip = HotmData.availableTokens.takeIf { it != 0 }?.let { "§b$it" } ?: "" + } + +} -- cgit