aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorraaaaaven <168305416+raaaaaven@users.noreply.github.com>2024-04-28 19:29:58 +0100
committerGitHub <noreply@github.com>2024-04-28 20:29:58 +0200
commit496cfdd7637cd1392fddd5ed49e750f4c7cd7afb (patch)
treed51138d9881e6341ed67b890ba1a7f02b52a2eab /src
parente9f9e7c8b8d5fe3c0a8560a493fdd52f54088a28 (diff)
downloadskyhanni-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')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/event/ChocolateFactoryConfig.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryShortcut.kt66
3 files changed, 74 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index a92e2fb1b..abb16f732 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -128,6 +128,7 @@ import at.hannibal2.skyhanni.features.event.UniqueGiftingOpportunitiesFeatures
import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryAPI
import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryBarnManager
import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryInventory
+import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryShortcut
import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryStats
import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityCollectionStats
import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityEggLocator
@@ -624,6 +625,7 @@ class SkyHanniMod {
loadModule(AreaMiniBossFeatures())
loadModule(MobHighlight())
loadModule(ChocolateFactoryBarnManager)
+ loadModule(ChocolateFactoryShortcut())
loadModule(ChocolateFactoryInventory)
loadModule(ChocolateFactoryStats)
loadModule(FactoryItemTooltipFeatures)
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/ChocolateFactoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/ChocolateFactoryConfig.java
index 2a0d47892..a15f399a5 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/event/ChocolateFactoryConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/ChocolateFactoryConfig.java
@@ -91,6 +91,12 @@ public class ChocolateFactoryConfig {
public boolean hoppityCollectionStats = true;
@Expose
+ @ConfigOption(name = "Hoppity Menu Shortcut", desc = "Add a Chocolate Factory button in the SkyBlock Menu that runs /chocolatefactory on click.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean hoppityMenuShortcut = true;
+
+ @Expose
@ConfigLink(owner = ChocolateFactoryConfig.class, field = "statsDisplay")
public Position position = new Position(183, 160, false, true);
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()
+ }
+ }
+ }
+}