diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-06-22 15:13:05 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-06-22 15:13:05 +0200 |
commit | b3e289dbec40cdd0632bac41f510d94af545983c (patch) | |
tree | 6c20750154b48e8ddac47d93b537b4dcbf5a8326 /src/main/java/at/hannibal2/skyhanni/features | |
parent | 80809a9d62e42155bc520848a1cdd55721d980b0 (diff) | |
download | skyhanni-b3e289dbec40cdd0632bac41f510d94af545983c.tar.gz skyhanni-b3e289dbec40cdd0632bac41f510d94af545983c.tar.bz2 skyhanni-b3e289dbec40cdd0632bac41f510d94af545983c.zip |
Add Rift Highlight Guide
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/rift/HighlightRiftGuide.kt | 63 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt | 4 |
2 files changed, 65 insertions, 2 deletions
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<Int>() + + @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<Int>() + 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<Long, String>() @SubscribeEvent - fun onConfigLoad(event: ConfigLoadEvent) { + fun onJoinWorld(ignored: WorldEvent.Load) { display = emptyList() } |