From 8b170c0dd2685358bb00cd73da06063cdb011961 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Sat, 4 May 2024 12:04:23 +0200 Subject: Fix: inventory hotkeys hotbar item move behaviour (#1690) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../hannibal2/skyhanni/features/inventory/HarpFeatures.kt | 11 +++++++++++ .../inventory/chocolatefactory/ChocolateFactoryInventory.kt | 6 +++++- .../inventory/chocolatefactory/ChocolateFactoryKeybinds.kt | 13 +++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) (limited to 'src/main') 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 44f8a51b6..71ce9c41e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt @@ -152,6 +152,17 @@ object HarpFeatures { @SubscribeEvent fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { if (!LorenzUtils.inSkyBlock) return + + if (isHarpGui(InventoryUtils.openInventoryName())) { + if (config.keybinds) { + // needed to not send duplicate clicks via keybind feature + if (event.clickTypeEnum == GuiContainerEvent.ClickType.HOTBAR) { + event.cancel() + return + } + } + } + if (!config.quickRestart) return if (!isMenuGui(InventoryUtils.openInventoryName())) return if (event.slot?.slotNumber != closeButtonSlot) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryInventory.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryInventory.kt index 42dcdae8a..587f265da 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryInventory.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryInventory.kt @@ -92,7 +92,11 @@ object ChocolateFactoryInventory { val slotNumber = slot.slotNumber if (!config.useMiddleClick) return if (slotNumber in ChocolateFactoryAPI.noPickblockSlots && - (slotNumber != ChocolateFactoryAPI.timeTowerIndex || event.clickedButton == 1)) return + (slotNumber != ChocolateFactoryAPI.timeTowerIndex || event.clickedButton == 1) + ) return + + // this would break ChocolateFactoryKeybinds otherwise + if (event.clickTypeEnum == GuiContainerEvent.ClickType.HOTBAR) return event.makePickblock() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryKeybinds.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryKeybinds.kt index ca4ec9705..2c0920db3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryKeybinds.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryKeybinds.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory +import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiKeyPressEvent import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyClicked import at.hannibal2.skyhanni.utils.LorenzUtils @@ -40,6 +41,18 @@ object ChocolateFactoryKeybinds { } } + @SubscribeEvent + fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!config.enabled) return + if (!ChocolateFactoryAPI.inChocolateFactory) return + + // needed to not send duplicate clicks via keybind feature + if (event.clickTypeEnum == GuiContainerEvent.ClickType.HOTBAR) { + event.cancel() + } + } + private fun getKey(index: Int) = when (index) { 0 -> config.key1 1 -> config.key2 -- cgit