diff options
5 files changed, 21 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index bcddda8df..aacbfc5c1 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -36,7 +36,7 @@ object Commands { private val openMainMenu: (Array<String>) -> Unit = { if (it.isNotEmpty()) { if (it[0].lowercase() == "gui") { - GuiEditManager.openGuiEditor() + GuiEditManager.openGuiPositionEditor() } else { ConfigGuiManager.openConfigGui(it.joinToString(" ")) } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/GUI.java b/src/main/java/at/hannibal2/skyhanni/config/features/GUI.java index 957f12f8f..e1a8f23c0 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/GUI.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/GUI.java @@ -11,7 +11,7 @@ public class GUI { @ConfigOption(name = "Edit GUI Locations", desc = "Change the position of SkyHanni's overlays") @ConfigEditorButton(buttonText = "Edit") - public Runnable positions = GuiEditManager::openGuiEditor; + public Runnable positions = GuiEditManager::openGuiPositionEditor; @Expose @ConfigOption(name = "Open Hotkey", desc = "Press this key to open the GUI Editor.") diff --git a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt index 54ff70886..f3d734dcb 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.config.core.config.Position import at.hannibal2.skyhanni.config.core.config.gui.GuiPositionEditor import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.isRancherSign import at.hannibal2.skyhanni.utils.NEUItems import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest @@ -34,8 +35,13 @@ class GuiEditManager { if (NEUItems.neuHasFocus()) return + val screen = Minecraft.getMinecraft().currentScreen + if (screen is GuiEditSign) { + if (!screen.isRancherSign()) return + } + if (isInGui()) return - openGuiEditor() + openGuiPositionEditor() } @SubscribeEvent(priority = EventPriority.LOWEST) @@ -63,7 +69,7 @@ class GuiEditManager { } @JvmStatic - fun openGuiEditor() { + fun openGuiPositionEditor() { SkyHanniMod.screenToOpen = GuiPositionEditor(latestPositions.values.toList(), 2) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt index 8653502d1..7905890ec 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt @@ -6,12 +6,11 @@ import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.isRancherSign import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher -import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.renderables.Renderable -import io.github.moulberry.notenoughupdates.mixins.AccessorGuiEditSign import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiEditSign import net.minecraftforge.client.event.GuiOpenEvent @@ -51,11 +50,7 @@ class GardenOptimalSpeed { if (!isRancherOverlayEnabled()) return val gui = event.gui if (gui !is GuiEditSign) return - gui as AccessorGuiEditSign - if (gui.tileSign.signText[1].unformattedText.removeColor() != "^^^^^^" - || gui.tileSign.signText[2].unformattedText.removeColor() != "Set your" - || gui.tileSign.signText[3].unformattedText.removeColor() != "speed cap!" - ) return + if (!gui.isRancherSign()) return config.optimalSpeedSignPosition.renderStringsAndItems( rancherOverlayList, posLabel = "Optimal Speed Rancher Overlay" diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 656030c97..054b8509c 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -363,4 +363,13 @@ object LorenzUtils { } return null } + + fun GuiEditSign.isRancherSign(): Boolean { + if (this !is AccessorGuiEditSign) return false + + val tileSign = (this as AccessorGuiEditSign).tileSign + return (tileSign.signText[1].unformattedText.removeColor() == "^^^^^^" + && tileSign.signText[2].unformattedText.removeColor() == "Set your" + && tileSign.signText[3].unformattedText.removeColor() == "speed cap!") + } }
\ No newline at end of file |