From 7216e9cbefa76927447b9c98f3d0934a03d9f87d Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 28 Apr 2024 13:39:49 +0200 Subject: [PATCH 1/4] Chocolate Factory Compact On Click --- .../java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 + .../event/ChocolateFactoryConfig.java | 6 +++ .../clicks/CompactFactoryClick.kt | 46 +++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/clicks/CompactFactoryClick.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 33d7cdbe94ec..885bffe30f03 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 344ee625e774..a088430f40f1 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,10 @@ 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; } 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 000000000000..c023bdb0c2c7 --- /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) return + val list = mutableListOf() + 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() + } + } + } +} From e1900635501a6007d530aec78f786d458b5fdde7 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 28 Apr 2024 14:36:11 +0200 Subject: [PATCH 2/4] Added Tooltip Move --- .../java/at/hannibal2/skyhanni/SkyHanniMod.kt | 4 +-- .../event/ChocolateFactoryConfig.java | 10 ++++++ ...Click.kt => FactoryItemTooltipFeatures.kt} | 33 ++++++++++++++++++- 3 files changed, 44 insertions(+), 3 deletions(-) rename src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/clicks/{CompactFactoryClick.kt => FactoryItemTooltipFeatures.kt} (59%) diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 885bffe30f03..a92e2fb1b3bf 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -133,7 +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.chocolatefactory.clicks.FactoryItemTooltipFeatures import at.hannibal2.skyhanni.features.event.diana.AllBurrowsList import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker @@ -626,7 +626,7 @@ class SkyHanniMod { loadModule(ChocolateFactoryBarnManager) loadModule(ChocolateFactoryInventory) loadModule(ChocolateFactoryStats) - loadModule(CompactFactoryClick) + loadModule(FactoryItemTooltipFeatures) 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 a088430f40f1..caf86f44276b 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 @@ -103,4 +103,14 @@ public class ChocolateFactoryConfig { @ConfigEditorBoolean @FeatureToggle public boolean compactOnClick = true; + + @Expose + @ConfigOption(name = "Tooltip Move", desc = "Move Tooltip away from the item you hover over while inside the Chocolate Factory.") + @ConfigEditorBoolean + @FeatureToggle + public boolean tooltipMove = false; + + @Expose + @ConfigLink(owner = ChocolateFactoryConfig.class, field = "tooltipMove") + public Position tooltipMovePosition = new Position(-380, 150, false, true); } 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/FactoryItemTooltipFeatures.kt similarity index 59% rename from src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/clicks/CompactFactoryClick.kt rename to src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/clicks/FactoryItemTooltipFeatures.kt index c023bdb0c2c7..159ac1bcee09 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/clicks/CompactFactoryClick.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/clicks/FactoryItemTooltipFeatures.kt @@ -1,24 +1,55 @@ package at.hannibal2.skyhanni.features.event.chocolatefactory.clicks import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.GuiRenderEvent 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.RenderUtils.renderStrings 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.milliseconds import kotlin.time.Duration.Companion.seconds -object CompactFactoryClick { +object FactoryItemTooltipFeatures { private val config get() = ChocolateFactoryAPI.config private var lastClick = SimpleTimeMark.farPast() + private var lastHover = SimpleTimeMark.farPast() + private var tooltipToHover = listOf() @SubscribeEvent fun onTooltip(event: LorenzToolTipEvent) { if (!ChocolateFactoryAPI.inChocolateFactory) return + + if (config.tooltipMove) { + if (event.slot.slotNumber <= 44) { + lastHover = SimpleTimeMark.now() + tooltipToHover = event.toolTip.toList() + event.cancel() + } else { + lastHover = SimpleTimeMark.farPast() + } + return + } + + onCompactClick(event) + } + + @SubscribeEvent + fun onBackgroundDraw(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { + if (!ChocolateFactoryAPI.inChocolateFactory) return + if (config.tooltipMove) { + if (lastHover.passedSince() < 300.milliseconds) { + config.tooltipMovePosition.renderStrings(tooltipToHover, posLabel = "Tooltip Move") + } + } + } + + private fun onCompactClick(event: LorenzToolTipEvent) { if (!config.compactOnClick) return val itemStack = event.itemStack From 3a8bf2afec4120a43fb8447c92878d63c53c9b34 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 28 Apr 2024 15:08:46 +0200 Subject: [PATCH 3/4] Added Always Compact --- .../config/features/event/ChocolateFactoryConfig.java | 7 ++++++- .../event/chocolatefactory/clicks/CompactFactoryClick.kt | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) 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 a088430f40f1..3aef751899df 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 @@ -99,8 +99,13 @@ public class ChocolateFactoryConfig { 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") + @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 index c023bdb0c2c7..64f30de0440e 100644 --- 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 @@ -24,7 +24,7 @@ object CompactFactoryClick { 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) return + if (lastClick.passedSince() >= 1.seconds && !config.compactOnClickAlways) return val list = mutableListOf() list.add(itemStack.name) lore.getOrNull(5)?.let { From 504630c18d1743fcd9ff5adf0bc918bccf65a66e Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 28 Apr 2024 15:58:49 +0200 Subject: [PATCH 4/4] merge conflicts --- .../clicks/CompactFactoryClick.kt | 46 ------------------- 1 file changed, 46 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/clicks/CompactFactoryClick.kt 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 deleted file mode 100644 index 64f30de0440e..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/clicks/CompactFactoryClick.kt +++ /dev/null @@ -1,46 +0,0 @@ -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() - 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() - } - } - } -}