diff options
author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-01-20 10:39:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-20 10:39:13 +0100 |
commit | 3b3487deaea5cbfda16382f6eeaeb7856ec368f0 (patch) | |
tree | 1743c1019358ff12b1a552425a9d608a6c22980d /src/main/java/at/hannibal2 | |
parent | a4fe926ce0765fdb5c776f8b8501c5d5c38e1f76 (diff) | |
download | skyhanni-3b3487deaea5cbfda16382f6eeaeb7856ec368f0.tar.gz skyhanni-3b3487deaea5cbfda16382f6eeaeb7856ec368f0.tar.bz2 skyhanni-3b3487deaea5cbfda16382f6eeaeb7856ec368f0.zip |
Feature: Shift Click in Brewing Stand (#921)
Added Shift Click Brewing. #921
Diffstat (limited to 'src/main/java/at/hannibal2')
6 files changed, 51 insertions, 19 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 2935c8222..bedfd4b33 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -209,6 +209,7 @@ import at.hannibal2.skyhanni.features.inventory.PowerStoneGuideFeatures import at.hannibal2.skyhanni.features.inventory.QuickCraftFeatures import at.hannibal2.skyhanni.features.inventory.RngMeterInventory import at.hannibal2.skyhanni.features.inventory.SackDisplay +import at.hannibal2.skyhanni.features.inventory.ShiftClickBrewing import at.hannibal2.skyhanni.features.inventory.ShiftClickEquipment import at.hannibal2.skyhanni.features.inventory.ShiftClickNPCSell import at.hannibal2.skyhanni.features.inventory.SkyBlockLevelGuideHelper @@ -478,6 +479,7 @@ class SkyHanniMod { loadModule(TrophyFishFillet()) loadModule(TrophyFishMessages()) loadModule(BazaarBestSellMethod()) + loadModule(ShiftClickBrewing()) loadModule(BazaarOpenPriceWebsite()) loadModule(AuctionHouseCopyUnderbidPrice()) loadModule(AnvilCombineHelper()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java index 0aed8ec3f..b01498728 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java @@ -194,4 +194,10 @@ public class InventoryConfig { @FeatureToggle public boolean shiftClickNPCSell = false; + @Expose + @ConfigOption(name = "Shift Click Brewing", desc = "Makes normal clicks to shift clicks in Brewing Stand inventory.") + @ConfigEditorBoolean + @FeatureToggle + public boolean shiftClickBrewing = false; + } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickBrewing.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickBrewing.kt new file mode 100644 index 000000000..0e7337bc0 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickBrewing.kt @@ -0,0 +1,27 @@ +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 at.hannibal2.skyhanni.utils.LorenzUtils.makeShiftClick +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class ShiftClickBrewing { + + @SubscribeEvent + fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!SkyHanniMod.feature.inventory.shiftClickBrewing) return + + if (event.gui !is GuiChest) return + + if (event.slot == null) return + + val chestName = InventoryUtils.openInventoryName() + if (!chestName.startsWith("Brewing Stand")) return + + event.makeShiftClick() + } +} 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 a472d4b90..4f9b08b20 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickEquipment.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickEquipment.kt @@ -4,7 +4,7 @@ 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 at.hannibal2.skyhanni.utils.LorenzUtils.makeShiftClick import net.minecraft.client.gui.inventory.GuiChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -26,13 +26,6 @@ class ShiftClickEquipment { 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 - ) + event.makeShiftClick() } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickNPCSell.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickNPCSell.kt index 9a18572b1..5e6c8bf6b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickNPCSell.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickNPCSell.kt @@ -6,9 +6,9 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.makeShiftClick import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern -import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object ShiftClickNPCSell { @@ -46,9 +46,6 @@ object ShiftClickNPCSell { if (slot.slotNumber == slot.slotIndex) return - event.isCanceled = true - Minecraft.getMinecraft().playerController.windowClick( - event.container.windowId, event.slot.slotNumber, event.clickedButton, 1, Minecraft.getMinecraft().thePlayer - ) + event.makeShiftClick() } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 572aa147f..666ea54ea 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.MayorElection import at.hannibal2.skyhanni.data.TitleManager +import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.mixins.transformers.AccessorGuiEditSign @@ -265,7 +266,7 @@ object LorenzUtils { fun getSBMonthByName(month: String): Int { var monthNr = 0 - for (i in 1 .. 12) { + for (i in 1..12) { val monthName = SkyBlockTime.monthName(i) if (month == monthName) { monthNr = i @@ -555,8 +556,8 @@ object LorenzUtils { val tileSign = (this as AccessorGuiEditSign).tileSign return (tileSign.signText[1].unformattedText.removeColor() == "^^^^^^" - && tileSign.signText[2].unformattedText.removeColor() == "Set your" - && tileSign.signText[3].unformattedText.removeColor() == "speed cap!") + && tileSign.signText[2].unformattedText.removeColor() == "Set your" + && tileSign.signText[3].unformattedText.removeColor() == "speed cap!") } fun IslandType.isInIsland() = inSkyBlock && skyBlockIsland == this @@ -629,6 +630,13 @@ object LorenzUtils { return this } + fun GuiContainerEvent.SlotClickEvent.makeShiftClick() = + slot?.slotNumber?.let { slotNumber -> + Minecraft.getMinecraft().playerController.windowClick( + container.windowId, slotNumber, 0, 1, Minecraft.getMinecraft().thePlayer + )?.also { isCanceled = true } + } + fun <T> List<T>.indexOfFirst(vararg args: T) = args.map { indexOf(it) }.firstOrNull { it != -1 } private val recalculateDerpy = @@ -696,6 +704,5 @@ object LorenzUtils { // Let garbage collector handle the removal of entries in this list fun <T> weakReferenceList(): MutableSet<T> = Collections.newSetFromMap(WeakHashMap<T, Boolean>()) - fun <T> MutableCollection<T>.filterToMutable(predicate: (T) -> Boolean) = filterTo(mutableListOf(), predicate) } |