aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2023-11-03 20:26:08 +0100
committerGitHub <noreply@github.com>2023-11-03 20:26:08 +0100
commitb3426297169836aceee7486bab89035c35c6d126 (patch)
tree66032e979ea6d25d58a07ec3b981fa3f5d3a89d6
parentba60af15b9f3ac89209a57b850f5f3a8488ceb56 (diff)
downloadskyhanni-b3426297169836aceee7486bab89035c35c6d126.tar.gz
skyhanni-b3426297169836aceee7486bab89035c35c6d126.tar.bz2
skyhanni-b3426297169836aceee7486bab89035c35c6d126.zip
Change: Custom Keybinds for Harp Helper (#612)
Add custom keybinds for Harp Helper. #612
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java38
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt46
3 files changed, 70 insertions, 16 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index ab2915ca8..544089711 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -591,7 +591,7 @@ class SkyHanniMod {
loadModule(GriffinPetWarning())
loadModule(BestiaryData)
loadModule(KingTalismanHelper())
- loadModule(HarpFeatures())
+ loadModule(HarpFeatures)
loadModule(EnderNodeTracker())
loadModule(CompactBestiaryChatMessage())
loadModule(WatchdogHider())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java
index 9a5f4759c..50128e85e 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java
@@ -8,8 +8,10 @@ import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
import io.github.moulberry.moulconfig.annotations.ConfigEditorColour;
import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList;
import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind;
import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider;
import io.github.moulberry.moulconfig.annotations.ConfigOption;
+import org.lwjgl.input.Keyboard;
import java.util.ArrayList;
import java.util.Arrays;
@@ -331,6 +333,42 @@ public class InventoryConfig {
@ConfigOption(name = "Show Numbers", desc = "In the Harp, show buttons as stack size (intended to be used with the Keybinds).")
@ConfigEditorBoolean
public boolean showNumbers = false;
+
+ @Expose
+ @ConfigOption(name = "Keybinds", desc = "")
+ @Accordion
+ public HarpConfigKeyBinds harpKeybinds = new HarpConfigKeyBinds();
+
+ public static class HarpConfigKeyBinds {
+ @Expose
+ @ConfigOption(name = "Key 1", desc = "Key for the first Node")
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_1)
+ public int key1 = Keyboard.KEY_1;
+ @Expose
+ @ConfigOption(name = "Key 2", desc = "Key for the second Node")
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_2)
+ public int key2 = Keyboard.KEY_2;
+ @Expose
+ @ConfigOption(name = "Key 3", desc = "Key for the third Node")
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_3)
+ public int key3 = Keyboard.KEY_3;
+ @Expose
+ @ConfigOption(name = "Key 4", desc = "Key for the fourth Node")
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_4)
+ public int key4 = Keyboard.KEY_4;
+ @Expose
+ @ConfigOption(name = "Key 5", desc = "Key for the fifth Node")
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_5)
+ public int key5 = Keyboard.KEY_5;
+ @Expose
+ @ConfigOption(name = "Key 6", desc = "Key for the sixth Node")
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_6)
+ public int key6 = Keyboard.KEY_6;
+ @Expose
+ @ConfigOption(name = "Key 7", desc = "Key for the seventh Node")
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_7)
+ public int key7 = Keyboard.KEY_7;
+ }
}
@Expose
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt
index e793cd615..3c0a40870 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt
@@ -12,23 +12,39 @@ import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.item.Item
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 HarpFeatures {
- private val config get() = SkyHanniMod.feature.inventory.helper.harp
+object HarpFeatures {
+ val config get() = SkyHanniMod.feature.inventory.helper.harp
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
- )
+ private object keys :
+ Iterable<Int> {
+ override fun iterator(): Iterator<Int> {
+ return object : Iterator<Int> {
+ private var currentIndex = 0
+
+ override fun hasNext(): Boolean {
+ return currentIndex < 7
+ }
+
+ override fun next(): Int {
+ return when (currentIndex++) {
+ 0 -> HarpFeatures.config.harpKeybinds.key1
+ 1 -> HarpFeatures.config.harpKeybinds.key2
+ 2 -> HarpFeatures.config.harpKeybinds.key3
+ 3 -> HarpFeatures.config.harpKeybinds.key4
+ 4 -> HarpFeatures.config.harpKeybinds.key5
+ 5 -> HarpFeatures.config.harpKeybinds.key6
+ 6 -> HarpFeatures.config.harpKeybinds.key7
+ else -> throw NoSuchElementException()
+ }
+ }
+ }
+ }
+
+ }
private val buttonColors = listOf('d', 'e', 'a', '2', '5', '9', 'b')
@@ -39,12 +55,12 @@ class HarpFeatures {
if (!openInventoryName().startsWith("Harp")) return
val chest = event.gui as? GuiChest ?: return
- for (key in keys) {
+ for ((index, key) in keys.withIndex()) {
if (key.isKeyHeld()) {
if (lastClick.passedSince() > 200.milliseconds) {
Minecraft.getMinecraft().playerController.windowClick(
chest.inventorySlots.windowId,
- 35 + key,
+ 37 + index,
2,
3,
Minecraft.getMinecraft().thePlayer
@@ -75,4 +91,4 @@ class HarpFeatures {
event.move(2, "misc.harpKeybinds", "inventory.helper.harp.keybinds")
event.move(2, "misc.harpNumbers", "inventory.helper.harp.showNumbers")
}
-} \ No newline at end of file
+}