From 8527d7555ea16becbcfe949413eabfd41c8400c4 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 11 Oct 2023 11:20:50 +0200 Subject: code cleanup and split merged if into 2 ifs to not have to call open inventory name when the feature is disabled. --- .../features/inventory/ShiftClickEquipment.kt | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickEquipment.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickEquipment.kt index f96405aad..a472d4b90 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickEquipment.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickEquipment.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.inventory import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -11,9 +12,10 @@ class ShiftClickEquipment { @SubscribeEvent fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { - if (event.gui !is GuiChest) return + if (!LorenzUtils.inSkyBlock) return + if (!SkyHanniMod.feature.inventory.shiftClickForEquipment) return - val chestName = InventoryUtils.openInventoryName() + if (event.gui !is GuiChest) return val slot = event.slot ?: return @@ -21,15 +23,16 @@ class ShiftClickEquipment { 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 - } + val chestName = InventoryUtils.openInventoryName() + if (!chestName.startsWith("Your Equipment")) return + + event.isCanceled = true + Minecraft.getMinecraft().playerController.windowClick( + event.container.windowId, + event.slot.slotNumber, + event.clickedButton, + 1, + Minecraft.getMinecraft().thePlayer + ) } } \ No newline at end of file -- cgit