diff options
author | Erymanthus[#5074] | (u/)RayDeeUx <51521765+RayDeeUx@users.noreply.github.com> | 2023-10-02 11:11:51 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-02 17:11:51 +0200 |
commit | 3a957574b11d4a3b897ac6b6519ed5689dda2b44 (patch) | |
tree | 39ccf90c006e095f6c0c45a5080a228d8479a4cc /src/main/java/io | |
parent | fe5d224ed60ae5717e88f5333d02b7699ea62f61 (diff) | |
download | NotEnoughUpdates-3a957574b11d4a3b897ac6b6519ed5689dda2b44.tar.gz NotEnoughUpdates-3a957574b11d4a3b897ac6b6519ed5689dda2b44.tar.bz2 NotEnoughUpdates-3a957574b11d4a3b897ac6b6519ed5689dda2b44.zip |
Add advanced wardrobe keybinds (#833)
Diffstat (limited to 'src/main/java/io')
2 files changed, 72 insertions, 7 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/WardrobeMouseButtons.kt b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/WardrobeMouseButtons.kt index f91e8d6e..65e23f3d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/WardrobeMouseButtons.kt +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/WardrobeMouseButtons.kt @@ -22,7 +22,11 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe import io.github.moulberry.notenoughupdates.core.config.KeybindHelper import io.github.moulberry.notenoughupdates.util.Utils +import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.inventory.ContainerChest +import net.minecraft.inventory.Slot +import net.minecraft.item.ItemStack import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -39,6 +43,9 @@ class WardrobeMouseButtons { NotEnoughUpdates.INSTANCE.config.wardrobeKeybinds.wardrobeSlot7, NotEnoughUpdates.INSTANCE.config.wardrobeKeybinds.wardrobeSlot8, NotEnoughUpdates.INSTANCE.config.wardrobeKeybinds.wardrobeSlot9, + NotEnoughUpdates.INSTANCE.config.wardrobeKeybinds.wardrobePageUnequip, + NotEnoughUpdates.INSTANCE.config.wardrobeKeybinds.wardrobePagePrevious, + NotEnoughUpdates.INSTANCE.config.wardrobeKeybinds.wardrobePageNext, ) private var lastClick = -1L @@ -57,17 +64,48 @@ class WardrobeMouseButtons { if (!NotEnoughUpdates.INSTANCE.config.wardrobeKeybinds.enableWardrobeKeybinds || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return val gui = event.gui as? GuiChest ?: return if (!Utils.getOpenChestName().contains("Wardrobe")) return + val chestName = Utils.getOpenChestName() + val chestNameRegex = "Wardrobe (\\((?<current>[0-9]+)\\/(?<total>[0-9]+)\\))".toRegex() + val chestNameMatch = chestNameRegex.matchEntire(chestName) + if (chestNameMatch == null) return + val totalPages = chestNameMatch.groups["total"]!!.value.toInt() + val currentPage = chestNameMatch.groups["current"]!!.value.toInt() + val guiChes = event.gui as GuiChest + val container = guiChes.inventorySlots as ContainerChest + var slotNum = 0 - for (i in keybinds.indices) { - if (KeybindHelper.isKeyDown(keybinds[i])) { - if (System.currentTimeMillis() - lastClick > 300) { - Utils.sendLeftMouseClick(gui.inventorySlots.windowId, 36 + i) - lastClick = System.currentTimeMillis() - event.isCanceled = true + if ((currentPage != totalPages) && KeybindHelper.isKeyDown(NotEnoughUpdates.INSTANCE.config.wardrobeKeybinds.wardrobePageNext)) { + slotNum = 53 + } else if ((currentPage != 1) && KeybindHelper.isKeyDown(NotEnoughUpdates.INSTANCE.config.wardrobeKeybinds.wardrobePagePrevious)) { + slotNum = 45 + } else if (KeybindHelper.isKeyDown(NotEnoughUpdates.INSTANCE.config.wardrobeKeybinds.wardrobePageUnequip)) { + var notEquipped = 0 + for (j in 36..44) { + val stackItem = container.getSlot(j).getStack() ?: return + if (stackItem.getDisplayName().contains("Equipped")) { + slotNum = j + } + else { + notEquipped++ + } + } + if (notEquipped == 9) return + } else { + for (i in keybinds.indices) { + if (KeybindHelper.isKeyDown(keybinds[i])) { + if (System.currentTimeMillis() - lastClick > 300) { + slotNum = (36 + i) + } } - break } } + + val thatItemStack = container.getSlot(slotNum).getStack() ?: return + if (thatItemStack.getDisplayName().isEmpty()) return + if (slotNum < 36 || ((slotNum > 45) && (slotNum != 53))) return + Utils.sendLeftMouseClick(gui.inventorySlots.windowId, slotNum) + lastClick = System.currentTimeMillis() + event.isCanceled = true } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WardrobeKeybinds.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WardrobeKeybinds.java index 48d1b434..a270a4a6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WardrobeKeybinds.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WardrobeKeybinds.java @@ -123,4 +123,31 @@ public class WardrobeKeybinds { @ConfigEditorKeybind(defaultKey = Keyboard.KEY_9) @ConfigAccordionId(id = 2) public int wardrobeSlot9 = Keyboard.KEY_9; + + @Expose + @ConfigOption( + name = "Unequip Wardrobe Slot", + desc = "Keybind to unequip the currently active set in your wardrobe" + ) + @ConfigEditorKeybind(defaultKey = Keyboard.KEY_0) + @ConfigAccordionId(id = 2) + public int wardrobePageUnequip = Keyboard.KEY_0; + + @Expose + @ConfigOption( + name = "Previous Page", + desc = "Keybind to open the previous page in your wardrobe" + ) + @ConfigEditorKeybind(defaultKey = Keyboard.KEY_MINUS) + @ConfigAccordionId(id = 2) + public int wardrobePagePrevious = Keyboard.KEY_MINUS; + + @Expose + @ConfigOption( + name = "Next Page", + desc = "Keybind to open the next page in your wardrobe" + ) + @ConfigEditorKeybind(defaultKey = Keyboard.KEY_EQUALS) + @ConfigAccordionId(id = 2) + public int wardrobePageNext = Keyboard.KEY_EQUALS; } |