From 5758183af143a62acf0ac8779bbe8d66e679ed11 Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Wed, 11 Oct 2023 11:18:17 +0200 Subject: Feature: Make normal clicks to shift clicks in equipment inventory (#519) Added Shift Click Equipment. #519 --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 ++ .../skyhanni/config/features/InventoryConfig.java | 5 ++++ .../features/inventory/ShiftClickEquipment.kt | 35 ++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickEquipment.kt (limited to 'src/main/java/at/hannibal2/skyhanni') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index c7bb40f39..2ef4de8e8 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -152,6 +152,7 @@ import at.hannibal2.skyhanni.features.inventory.RngMeterInventory import at.hannibal2.skyhanni.features.inventory.SackDisplay import at.hannibal2.skyhanni.features.inventory.SkyBlockLevelGuideHelper import at.hannibal2.skyhanni.features.inventory.StatsTuning +import at.hannibal2.skyhanni.features.inventory.ShiftClickEquipment import at.hannibal2.skyhanni.features.itemabilities.FireVeilWandParticles import at.hannibal2.skyhanni.features.itemabilities.abilitycooldown.ItemAbilityCooldown import at.hannibal2.skyhanni.features.mining.HighlightMiningCommissionMobs @@ -589,6 +590,7 @@ class SkyHanniMod { loadModule(SkyBlockKickDuration()) loadModule(LimboTimeTracker()) loadModule(PartyMemberOutlines()) + loadModule(ShiftClickEquipment()) init() 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 993746999..adf684a84 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java @@ -418,5 +418,10 @@ public class InventoryConfig { @FeatureToggle public boolean highlightAuctions = true; + @Expose + @ConfigOption(name = "Shift Click Equipment", desc = "Makes normal clicks to shift clicks in equipment inventory") + @ConfigEditorBoolean + @FeatureToggle + public boolean shiftClickForEquipment = false; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickEquipment.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickEquipment.kt new file mode 100644 index 000000000..f96405aad --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickEquipment.kt @@ -0,0 +1,35 @@ +package at.hannibal2.skyhanni.features.inventory + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.utils.InventoryUtils +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class ShiftClickEquipment { + + @SubscribeEvent + fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { + if (event.gui !is GuiChest) return + + val chestName = InventoryUtils.openInventoryName() + + val slot = event.slot ?: return + + if (slot.slotNumber == slot.slotIndex) return + + if (slot.stack == null) return + + if (SkyHanniMod.feature.inventory.shiftClickForEquipment && chestName.startsWith("Your Equipment")) { + Minecraft.getMinecraft().playerController.windowClick( + event.container.windowId, + event.slot.slotNumber, + event.clickedButton, + 1, + Minecraft.getMinecraft().thePlayer + ) + event.isCanceled = true + } + } +} \ No newline at end of file -- cgit