From b3e289dbec40cdd0632bac41f510d94af545983c Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 22 Jun 2023 15:13:05 +0200 Subject: Add Rift Highlight Guide --- .../skyhanni/features/rift/HighlightRiftGuide.kt | 63 ++++++++++++++++++++++ .../hannibal2/skyhanni/features/rift/RiftTimer.kt | 4 +- 2 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/rift/HighlightRiftGuide.kt (limited to 'src/main/java/at/hannibal2/skyhanni/features') diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/HighlightRiftGuide.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/HighlightRiftGuide.kt new file mode 100644 index 000000000..a8bf69fba --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/HighlightRiftGuide.kt @@ -0,0 +1,63 @@ +package at.hannibal2.skyhanni.features.rift + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.InventoryOpenEvent +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class HighlightRiftGuide { + private val config get() = SkyHanniMod.feature.rift + private var inInventory = false + private var highlightedItems = listOf() + + @SubscribeEvent + fun onInventoryOpen(event: InventoryOpenEvent) { + inInventory = false + + if (!isEnabled()) return + + val inGuide = event.inventoryItems[40]?.getLore()?.let { + if (it.size == 1) { + it[0] == "§7To Rift Guide" + } else false + } ?: false + if (!inGuide) return + + val highlightedItems = mutableListOf() + for ((slot, stack) in event.inventoryItems) { + val lore = stack.getLore() + if (lore.isNotEmpty()) { + if (lore.last() == "§8✖ Not completed yet!") { + highlightedItems.add(slot) + } + } + } + inInventory = true + this.highlightedItems = highlightedItems + } + + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + inInventory = false + } + + @SubscribeEvent(priority = EventPriority.LOW) + fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!isEnabled()) return + if (!inInventory) return + + for (slot in InventoryUtils.getItemsInOpenChest()) { + if (slot.slotIndex in highlightedItems) { + slot highlight LorenzColor.YELLOW + } + } + } + + fun isEnabled() = RiftAPI.inRift() && config.highlightGuide +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt index c95393ac2..6fe16c981 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt @@ -1,7 +1,6 @@ package at.hannibal2.skyhanni.features.rift import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzActionBarEvent import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -9,6 +8,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.TimeUtils +import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class RiftTimer { @@ -19,7 +19,7 @@ class RiftTimer { private val changes = mutableMapOf() @SubscribeEvent - fun onConfigLoad(event: ConfigLoadEvent) { + fun onJoinWorld(ignored: WorldEvent.Load) { display = emptyList() } -- cgit