diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-04-30 12:35:46 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-04-30 12:36:11 +0200 |
commit | cfb2867ed0e00a7c6f5f0b855837e5f834f6c39f (patch) | |
tree | 8b65fb4051b292278b98b12cdd10921fd2f20980 /src/main/java/at/hannibal2/skyhanni/features | |
parent | 67a0f9dd405dd4d2333dde81bee3827fea20a65f (diff) | |
download | skyhanni-cfb2867ed0e00a7c6f5f0b855837e5f834f6c39f.tar.gz skyhanni-cfb2867ed0e00a7c6f5f0b855837e5f834f6c39f.tar.bz2 skyhanni-cfb2867ed0e00a7c6f5f0b855837e5f834f6c39f.zip |
Used workaround to fix problems with left click hotkey triggering after sign click
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCustomKeybinds.kt | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCustomKeybinds.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCustomKeybinds.kt index 0cde5344c..367d7009b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCustomKeybinds.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCustomKeybinds.kt @@ -17,6 +17,7 @@ object GardenCustomKeybinds { private val mcSettings get() = Minecraft.getMinecraft().gameSettings private val map: MutableMap<KeyBinding, () -> Int> = IdentityHashMap() + private var lastWindowOpenTime = 0L init { map[mcSettings.keyBindAttack] = { shConfig.keyBindAttack } @@ -31,8 +32,20 @@ object GardenCustomKeybinds { private fun isEnabled() = GardenAPI.inGarden() && shConfig.keyBindEnabled - private fun isActive() = isEnabled() && GardenAPI.toolInHand != null && Minecraft.getMinecraft().currentScreen == null + private fun isActive(): Boolean { + if (!isEnabled()) return false + if (GardenAPI.toolInHand == null) return false + if (Minecraft.getMinecraft().currentScreen != null) { + lastWindowOpenTime = System.currentTimeMillis() + return false + } + + // TODO remove workaround + if (System.currentTimeMillis() < lastWindowOpenTime + 300) return false + + return true + } private fun isHeld(keyCode: Int): Boolean { if (keyCode == 0) return false |