From 80f09d2de3b32935f8b6646353d807f037ba25bb Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Fri, 2 Aug 2024 10:58:05 +0200 Subject: Fix: Reputation helper keybind activating while inside GUIs. (#2284) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../reputationhelper/CrimsonIsleReputationHelper.kt | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni') diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt index 803cedb78..6e1b73cd0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt @@ -21,10 +21,13 @@ import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.TabListData import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.inventory.GuiInventory import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -52,7 +55,7 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { */ val tabListQuestPattern by RepoPattern.pattern( "crimson.reputation.tablist", - " §r§[cdea].*" + " §r§[cdea].*", ) init { @@ -143,16 +146,26 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { if (!config.enabled.get()) return if (!IslandType.CRIMSON_ISLE.isInIsland()) return - if (config.useHotkey && !config.hotkey.isKeyHeld()) { + if (config.useHotkey && !isHotkeyHeld()) { return } config.position.renderStringsAndItems( display, - posLabel = "Crimson Isle Reputation Helper" + posLabel = "Crimson Isle Reputation Helper", ) } + fun isHotkeyHeld(): Boolean { + val isAllowedGui = Minecraft.getMinecraft().currentScreen.let { + it == null || it is GuiInventory + } + if (!isAllowedGui) return false + if (NEUItems.neuHasFocus()) return false + + return config.hotkey.isKeyHeld() + } + @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(2, "misc.crimsonIsleReputationHelper", "crimsonIsle.reputationHelper.enabled") @@ -193,7 +206,7 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { fun showLocations() = when (config.showLocation) { ShowLocationEntry.ALWAYS -> true - ShowLocationEntry.ONLY_HOTKEY -> config.hotkey.isKeyHeld() + ShowLocationEntry.ONLY_HOTKEY -> isHotkeyHeld() else -> false } } -- cgit