aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/inventory/customwardrobe/CustomWardrobeConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/inventory/customwardrobe/KeybindConfig.java91
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/GuiData.kt15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobeKeybinds.kt53
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/WardrobeAPI.kt2
6 files changed, 164 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/customwardrobe/CustomWardrobeConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/customwardrobe/CustomWardrobeConfig.java
index 0d8212e3a..36f1d68d0 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/customwardrobe/CustomWardrobeConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/customwardrobe/CustomWardrobeConfig.java
@@ -63,4 +63,9 @@ public class CustomWardrobeConfig {
@ConfigOption(name = "Spacing", desc = "")
@Accordion
public SpacingConfig spacing = new SpacingConfig();
+
+ @Expose
+ @ConfigOption(name = "Keybinds", desc = "")
+ @Accordion
+ public KeybindConfig keybinds = new KeybindConfig();
}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/customwardrobe/KeybindConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/customwardrobe/KeybindConfig.java
new file mode 100644
index 000000000..95b5fd627
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/customwardrobe/KeybindConfig.java
@@ -0,0 +1,91 @@
+package at.hannibal2.skyhanni.config.features.inventory.customwardrobe;
+
+import com.google.gson.annotations.Expose;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorKeybind;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
+import org.lwjgl.input.Keyboard;
+
+public class KeybindConfig {
+
+ @Expose
+ @ConfigOption(
+ name = "Slot Keybinds Toggle",
+ desc = "Enable/Disable the slot keybinds.\n§cThis only works inside the Custom Wardrobe GUI."
+ )
+ @ConfigEditorBoolean
+ public boolean slotKeybindsToggle = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Slot 1",
+ desc = "Keybind for slot 1"
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_1)
+ public int slot1 = Keyboard.KEY_1;
+
+ @Expose
+ @ConfigOption(
+ name = "Slot 2",
+ desc = "Keybind for slot 2"
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_2)
+ public int slot2 = Keyboard.KEY_2;
+
+ @Expose
+ @ConfigOption(
+ name = "Slot 3",
+ desc = "Keybind for slot 3"
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_3)
+ public int slot3 = Keyboard.KEY_3;
+
+ @Expose
+ @ConfigOption(
+ name = "Slot 4",
+ desc = "Keybind for slot 4"
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_4)
+ public int slot4 = Keyboard.KEY_4;
+
+ @Expose
+ @ConfigOption(
+ name = "Slot 5",
+ desc = "Keybind for slot 5"
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_5)
+ public int slot5 = Keyboard.KEY_5;
+
+ @Expose
+ @ConfigOption(
+ name = "Slot 6",
+ desc = "Keybind for slot 6"
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_6)
+ public int slot6 = Keyboard.KEY_6;
+
+ @Expose
+ @ConfigOption(
+ name = "Slot 7",
+ desc = "Keybind for slot 7"
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_7)
+ public int slot7 = Keyboard.KEY_7;
+
+ @Expose
+ @ConfigOption(
+ name = "Slot 8",
+ desc = "Keybind for slot 8"
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_8)
+ public int slot8 = Keyboard.KEY_8;
+
+ @Expose
+ @ConfigOption(
+ name = "Slot 9",
+ desc = "Keybind for slot 9"
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_9)
+ public int slot9 = Keyboard.KEY_9;
+
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/GuiData.kt b/src/main/java/at/hannibal2/skyhanni/data/GuiData.kt
index 782f3224a..a96574a2b 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/GuiData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/GuiData.kt
@@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.NEURenderEvent
import at.hannibal2.skyhanni.events.minecraft.ClientDisconnectEvent
+import at.hannibal2.skyhanni.features.inventory.wardrobe.CustomWardrobeKeybinds
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld
@@ -40,10 +41,18 @@ object GuiData {
@SubscribeEvent(priority = EventPriority.HIGH)
fun onGuiKeyPress(event: GuiScreenEvent.KeyboardInputEvent.Pre) {
- val (escKey, invKey) = Minecraft.getMinecraft().gameSettings.let {
- Keyboard.KEY_ESCAPE to it.keyBindInventory.keyCode
+ val keys = Minecraft.getMinecraft().gameSettings.let {
+ listOf(
+ Keyboard.KEY_ESCAPE,
+ it.keyBindInventory.keyCode,
+ it.keyBindScreenshot.keyCode,
+ it.keyBindFullscreen.keyCode,
+ )
}
- if (escKey.isKeyHeld() || invKey.isKeyHeld()) return
+ if (keys.any { it.isKeyHeld() }) return
+
+ if (CustomWardrobeKeybinds.allowKeyboardClick()) return
+
if (preDrawEventCancelled) event.isCanceled = true
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt
index ff9a7610a..1c3f36aeb 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt
@@ -111,8 +111,7 @@ object CustomWardrobe {
@SubscribeEvent
fun onInventoryClose(event: InventoryCloseEvent) {
waitingForInventoryUpdate = false
- if (!isEnabled()) return
- DelayedRun.runDelayed(250.milliseconds) {
+ DelayedRun.runDelayed(300.milliseconds) {
if (!WardrobeAPI.inWardrobe()) {
reset()
}
@@ -587,7 +586,7 @@ object CustomWardrobe {
}
}
- private fun WardrobeSlot.clickSlot() {
+ fun WardrobeSlot.clickSlot() {
val previousPageSlot = 45
val nextPageSlot = 53
val wardrobePage = WardrobeAPI.currentPage ?: return
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobeKeybinds.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobeKeybinds.kt
new file mode 100644
index 000000000..2e3716cb2
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobeKeybinds.kt
@@ -0,0 +1,53 @@
+package at.hannibal2.skyhanni.features.inventory.wardrobe
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.GuiKeyPressEvent
+import at.hannibal2.skyhanni.features.inventory.wardrobe.CustomWardrobe.clickSlot
+import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
+import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyClicked
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.time.Duration.Companion.milliseconds
+
+@SkyHanniModule
+object CustomWardrobeKeybinds {
+
+ private val config get() = SkyHanniMod.feature.inventory.customWardrobe
+ private val keybinds
+ get() = listOf(
+ config.keybinds.slot1,
+ config.keybinds.slot2,
+ config.keybinds.slot3,
+ config.keybinds.slot4,
+ config.keybinds.slot5,
+ config.keybinds.slot6,
+ config.keybinds.slot7,
+ config.keybinds.slot8,
+ config.keybinds.slot9,
+ )
+ var lastClick = SimpleTimeMark.farPast()
+
+ @SubscribeEvent
+ fun onGui(event: GuiKeyPressEvent) {
+ if (!isEnabled()) return
+ val slots = WardrobeAPI.slots.filter { it.isInCurrentPage() }
+
+ for ((key, index) in keybinds.withIndex().map { it.value to it.index }) {
+ if (!key.isKeyClicked()) continue
+ if (lastClick.passedSince() < 200.milliseconds) break
+ val slot = slots.getOrNull(index) ?: continue
+
+ event.cancel()
+
+ slot.clickSlot()
+ lastClick = SimpleTimeMark.now()
+ break
+ }
+ }
+
+ fun allowKeyboardClick() = isEnabled() && keybinds.any { it.isKeyClicked() }
+
+ private fun isEnabled() = LorenzUtils.inSkyBlock && WardrobeAPI.inCustomWardrobe && config.keybinds.slotKeybindsToggle && config.enabled
+
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/WardrobeAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/WardrobeAPI.kt
index b49ba106a..f57761102 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/WardrobeAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/WardrobeAPI.kt
@@ -44,7 +44,7 @@ object WardrobeAPI {
"§7Slot \\d+: §aEquipped",
)
- private const val FIRST_SLOT = 36
+ const val FIRST_SLOT = 36
private const val FIRST_HELMET_SLOT = 0
private const val FIRST_CHESTPLATE_SLOT = 9
private const val FIRST_LEGGINGS_SLOT = 18