aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-04-28 15:21:44 +0200
committerGitHub <noreply@github.com>2024-04-28 15:21:44 +0200
commit6a6e17ee589ff9d0e5169fcfe4788c85f4a0529b (patch)
tree253895b01a55324280dc4211cc45749115e8de41 /src/main
parent5e8c03a938d77855bc40c43be8e6df60f3136c74 (diff)
downloadskyhanni-6a6e17ee589ff9d0e5169fcfe4788c85f4a0529b.tar.gz
skyhanni-6a6e17ee589ff9d0e5169fcfe4788c85f4a0529b.tar.bz2
skyhanni-6a6e17ee589ff9d0e5169fcfe4788c85f4a0529b.zip
Feature: Chocolate Factory Compact On Click (#1579)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/event/ChocolateFactoryConfig.java11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/clicks/CompactFactoryClick.kt46
3 files changed, 59 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 33d7cdbe9..885bffe30 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -133,6 +133,7 @@ import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityCollectionSt
import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityEggLocator
import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityEggsManager
import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityEggsShared
+import at.hannibal2.skyhanni.features.event.chocolatefactory.clicks.CompactFactoryClick
import at.hannibal2.skyhanni.features.event.diana.AllBurrowsList
import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper
import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker
@@ -625,6 +626,7 @@ class SkyHanniMod {
loadModule(ChocolateFactoryBarnManager)
loadModule(ChocolateFactoryInventory)
loadModule(ChocolateFactoryStats)
+ loadModule(CompactFactoryClick)
loadModule(HoppityEggsManager)
loadModule(HoppityEggLocator)
loadModule(HoppityEggsShared)
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 344ee625e..3aef75189 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
@@ -97,4 +97,15 @@ public class ChocolateFactoryConfig {
@Expose
@ConfigLink(owner = ChocolateFactoryConfig.class, field = "hoppityCollectionStats")
public Position hoppityStatsPosition = new Position(183, 160, false, true);
+
+ @Expose
+ @ConfigOption(name = "Compact On Click", desc = "Compact the item toolip when clicking on the chocolate.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean compactOnClick = true;
+
+ @Expose
+ @ConfigOption(name = "Always Compact", desc = "Always Compact the item toolip on the chocolate. Requires the above option to be enabled.")
+ @ConfigEditorBoolean
+ public boolean compactOnClickAlways = false;
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/clicks/CompactFactoryClick.kt b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/clicks/CompactFactoryClick.kt
new file mode 100644
index 000000000..64f30de04
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/clicks/CompactFactoryClick.kt
@@ -0,0 +1,46 @@
+package at.hannibal2.skyhanni.features.event.chocolatefactory.clicks
+
+import at.hannibal2.skyhanni.events.GuiContainerEvent
+import at.hannibal2.skyhanni.events.LorenzToolTipEvent
+import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryAPI
+import at.hannibal2.skyhanni.utils.CollectionUtils.getOrNull
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.ItemUtils.name
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import net.minecraftforge.fml.common.eventhandler.EventPriority
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.time.Duration.Companion.seconds
+
+object CompactFactoryClick {
+ private val config get() = ChocolateFactoryAPI.config
+
+ private var lastClick = SimpleTimeMark.farPast()
+
+ @SubscribeEvent
+ fun onTooltip(event: LorenzToolTipEvent) {
+ if (!ChocolateFactoryAPI.inChocolateFactory) return
+ if (!config.compactOnClick) return
+
+ val itemStack = event.itemStack
+ val lore = itemStack.getLore()
+ if (!lore.any { it == "§7§eClick to uncover the meaning of life!" }) return
+ if (lastClick.passedSince() >= 1.seconds && !config.compactOnClickAlways) return
+ val list = mutableListOf<String>()
+ list.add(itemStack.name)
+ lore.getOrNull(5)?.let {
+ list.add(it)
+ }
+ event.toolTip = list
+ return
+ }
+
+ @SubscribeEvent(priority = EventPriority.HIGH)
+ fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) {
+
+ if (ChocolateFactoryAPI.inChocolateFactory) {
+ if (event.slotId == 13) {
+ lastClick = SimpleTimeMark.now()
+ }
+ }
+ }
+}