diff options
author | raaaaaven <168305416+raaaaaven@users.noreply.github.com> | 2024-04-28 19:29:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-28 20:29:58 +0200 |
commit | 496cfdd7637cd1392fddd5ed49e750f4c7cd7afb (patch) | |
tree | d51138d9881e6341ed67b890ba1a7f02b52a2eab /src/main/java/at/hannibal2/skyhanni/features/event | |
parent | e9f9e7c8b8d5fe3c0a8560a493fdd52f54088a28 (diff) | |
download | skyhanni-496cfdd7637cd1392fddd5ed49e750f4c7cd7afb.tar.gz skyhanni-496cfdd7637cd1392fddd5ed49e750f4c7cd7afb.tar.bz2 skyhanni-496cfdd7637cd1392fddd5ed49e750f4c7cd7afb.zip |
Feature: Chocolate factory shortcut (#1583)
Co-authored-by: martimavocado <39881008+martimavocado@users.noreply.github.com>
Co-authored-by: raven <raveeeennnn@hotmail.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/event')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryShortcut.kt | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryShortcut.kt b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryShortcut.kt new file mode 100644 index 000000000..b28acd995 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryShortcut.kt @@ -0,0 +1,66 @@ +package at.hannibal2.skyhanni.features.event.chocolatefactory + +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.utils.HypixelCommands +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import at.hannibal2.skyhanni.utils.NEUItems.getItemStack +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import io.github.moulberry.notenoughupdates.events.ReplaceItemEvent +import io.github.moulberry.notenoughupdates.util.Utils +import net.minecraft.client.player.inventory.ContainerLocalMenu +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds + +class ChocolateFactoryShortcut { + + private val config get() = ChocolateFactoryAPI.config + private var showItem = false + private var lastClick = SimpleTimeMark.farPast() + + private val item by lazy { + val neuItem = "COOKIE".asInternalName().getItemStack() + Utils.createItemStack( + neuItem.item, + "§6Open Chocolate Factory", + "§8(From SkyHanni)", + "", + "§7Click here to run", + "§e/chocolatefactory" + ) + } + + @SubscribeEvent + fun onInventoryOpen(event: InventoryFullyOpenedEvent) { + if (RiftAPI.inRift()) return + if (!LorenzUtils.inSkyBlock) return + showItem = config.hoppityMenuShortcut && event.inventoryName == "SkyBlock Menu" + } + + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + showItem = false + } + + @SubscribeEvent + fun replaceItem(event: ReplaceItemEvent) { + if (event.inventory is ContainerLocalMenu && showItem && event.slotNumber == 15) { + event.replaceWith(item) + } + } + + @SubscribeEvent(priority = EventPriority.HIGH) + fun onStackClick(event: GuiContainerEvent.SlotClickEvent) { + if (showItem && event.slotId == 15) { + event.cancel() + if (lastClick.passedSince() > 2.seconds) { + HypixelCommands.chocolateFactory() + lastClick = SimpleTimeMark.now() + } + } + } +} |