aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/HarpKeybinds.kt49
3 files changed, 55 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 97ea42e45..3106933b4 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -367,6 +367,7 @@ class SkyHanniMod {
loadModule(RiftHorsezookaHider())
loadModule(GriffinPetWarning())
loadModule(KingTalismanHelper())
+ loadModule(HarpKeybinds())
//
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java
index 83fb12977..14d5624ff 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java
@@ -681,6 +681,11 @@ public class MiscConfig {
public boolean patcherSendCoordWaypoint = false;
@Expose
+ @ConfigOption(name = "Harp Keybinds", desc = "Press harp buttons with your number row on the keyboard instead of clicking.")
+ @ConfigEditorBoolean
+ public boolean harpKeybinds = false;
+
+ @Expose
@ConfigOption(name = "Config Button", desc = "Add a button to the pause menu to configure SkyHanni.")
@ConfigEditorBoolean
public boolean configButtonOnPause = true;
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/HarpKeybinds.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/HarpKeybinds.kt
new file mode 100644
index 000000000..08bb4cfee
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/HarpKeybinds.kt
@@ -0,0 +1,49 @@
+package at.hannibal2.skyhanni.features.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.utils.InventoryUtils.openInventoryName
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.inventory.GuiChest
+import net.minecraftforge.client.event.GuiScreenEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import org.lwjgl.input.Keyboard
+import kotlin.time.Duration.Companion.milliseconds
+
+// Delaying key presses by 300ms comes from NotEnoughUpdates
+class HarpKeybinds {
+ private var lastClick = SimpleTimeMark.farPast()
+
+ private val keys = listOf(
+ Keyboard.KEY_1,
+ Keyboard.KEY_2,
+ Keyboard.KEY_3,
+ Keyboard.KEY_4,
+ Keyboard.KEY_5,
+ Keyboard.KEY_6,
+ Keyboard.KEY_7
+ )
+
+ @SubscribeEvent
+ fun onGui(event: GuiScreenEvent) {
+ if (!SkyHanniMod.feature.misc.harpKeybinds) return
+ if (!openInventoryName().startsWith("Harp")) return
+ val chest = event.gui as? GuiChest ?: return
+
+ for (key in keys) {
+ if (Keyboard.isKeyDown(key)) {
+ if (lastClick.passedSince() > 200.milliseconds) {
+ Minecraft.getMinecraft().playerController.windowClick(
+ chest.inventorySlots.windowId,
+ 35 + key,
+ 2,
+ 3,
+ Minecraft.getMinecraft().thePlayer
+ ) // middle clicks > left clicks
+ lastClick = SimpleTimeMark.now()
+ }
+ break
+ }
+ }
+ }
+} \ No newline at end of file