diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-04-28 15:21:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-28 15:21:44 +0200 |
commit | 6a6e17ee589ff9d0e5169fcfe4788c85f4a0529b (patch) | |
tree | 253895b01a55324280dc4211cc45749115e8de41 /src/main/java/at/hannibal2/skyhanni/features/event | |
parent | 5e8c03a938d77855bc40c43be8e6df60f3136c74 (diff) | |
download | skyhanni-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/java/at/hannibal2/skyhanni/features/event')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/clicks/CompactFactoryClick.kt | 46 |
1 files changed, 46 insertions, 0 deletions
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() + } + } + } +} |