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 --- .../features/inventory/ShiftClickEquipment.kt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickEquipment.kt (limited to 'src/main/java/at/hannibal2/skyhanni/features') 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