diff options
author | MTOnline69 <97001154+MTOnline69@users.noreply.github.com> | 2024-09-30 00:44:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-30 01:44:22 +0200 |
commit | e4e8a313b66d67107a64db9873996ec58d76566d (patch) | |
tree | e68bec91a666bad6c5a305295b277f146119afd7 /src/main/java/at/hannibal2/skyhanni/features/rift | |
parent | 81bf379423633cbfa4f549f099a3fe8ef7e898c5 (diff) | |
download | skyhanni-e4e8a313b66d67107a64db9873996ec58d76566d.tar.gz skyhanni-e4e8a313b66d67107a64db9873996ec58d76566d.tar.bz2 skyhanni-e4e8a313b66d67107a64db9873996ec58d76566d.zip |
Feature: West Village/Dreadfarm/Living Cave features (#2616)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/rift')
9 files changed, 382 insertions, 41 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt index 844ac0227..48fa8d03f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt @@ -21,6 +21,11 @@ object RiftAPI { val farmingTool by lazy { "FARMING_WAND".asInternalName() } + private val blowgun by lazy { "BERBERIS_BLOWGUN".asInternalName() } + + val ItemStack?.isBlowgun: Boolean + get() = this?.getInternalName() == blowgun + fun ItemStack.motesNpcPrice(): Double? { val baseMotes = motesPrice[getInternalName()] ?: return null val burgerStacks = config.motes.burgerStacks @@ -28,9 +33,13 @@ object RiftAPI { return pricePer * stackSize } + var inRiftRace = false + var trackingButtons = false + var allButtonsHit = false + fun inLivingCave() = LorenzUtils.skyBlockArea == "Living Cave" fun inLivingStillness() = LorenzUtils.skyBlockArea == "Living Stillness" fun inStillgoreChateau() = LorenzUtils.skyBlockArea.let { it == "Stillgore Château" || it == "Oubliette" } - fun inDreadfarm() = LorenzUtils.skyBlockArea == "Dreadfarm" + fun inWestVillage() = LorenzUtils.skyBlockArea.let { it == "West Village" || it == "Infested House" } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt index e1664e6c8..9ff96213b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt @@ -1,7 +1,9 @@ package at.hannibal2.skyhanni.features.rift.area.dreadfarm +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.PlaySoundEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @@ -56,10 +58,9 @@ object RiftWiltedBerberisHelper { } } - private fun nearestBerberis(location: LorenzVec): WiltedBerberis? { - return list.filter { it.currentParticles.distanceSq(location) < 8 } + private fun nearestBerberis(location: LorenzVec): WiltedBerberis? = + list.filter { it.currentParticles.distanceSq(location) < 8 } .minByOrNull { it.currentParticles.distanceSq(location) } - } @SubscribeEvent fun onReceiveParticle(event: ReceiveParticleEvent) { @@ -70,13 +71,13 @@ object RiftWiltedBerberisHelper { val berberis = nearestBerberis(location) if (event.type != EnumParticleTypes.FIREWORKS_SPARK) { - if (config.hideparticles && berberis != null) { + if (config.hideParticles && berberis != null) { event.cancel() } return } - if (config.hideparticles) { + if (config.hideParticles) { event.cancel() } @@ -107,6 +108,16 @@ object RiftWiltedBerberisHelper { } @SubscribeEvent + fun onPlaySound(event: PlaySoundEvent) { + if (!isMuteOthersSoundsEnabled()) return + val soundName = event.soundName + + if (soundName == "mob.horse.donkey.death" || soundName == "mob.horse.donkey.hit") { + event.cancel() + } + } + + @SubscribeEvent fun onRenderWorld(event: LorenzRenderWorldEvent) { if (!isEnabled()) return if (!hasFarmingToolInHand) return @@ -133,6 +144,11 @@ object RiftWiltedBerberisHelper { } } + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(60, "rift.area.dreadfarm.wiltedBerberis.hideparticles", "rift.area.dreadfarm.wiltedBerberis.hideParticles") + } + private fun axisAlignedBB(loc: LorenzVec) = loc.add(0.1, -0.1, 0.1).boundingToOffset(0.8, 1.0, 0.8).expandBlock() private fun LorenzVec.fixLocation(wiltedBerberis: WiltedBerberis): LorenzVec { @@ -143,4 +159,9 @@ object RiftWiltedBerberisHelper { } private fun isEnabled() = RiftAPI.inRift() && RiftAPI.inDreadfarm() && config.enabled + + private fun isMuteOthersSoundsEnabled() = RiftAPI.inRift() && + config.muteOthersSounds && + (RiftAPI.inDreadfarm() || RiftAPI.inWestVillage()) && + !(hasFarmingToolInHand && isOnFarmland) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/WoodenButtonsHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/WoodenButtonsHelper.kt new file mode 100644 index 000000000..d2413cc3a --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/WoodenButtonsHelper.kt @@ -0,0 +1,184 @@ +package at.hannibal2.skyhanni.features.rift.area.dreadfarm + +import at.hannibal2.skyhanni.data.ClickType +import at.hannibal2.skyhanni.data.IslandGraphs +import at.hannibal2.skyhanni.data.jsonobjects.repo.RiftWoodenButtonsJson +import at.hannibal2.skyhanni.data.model.GraphNode +import at.hannibal2.skyhanni.data.model.GraphNodeTag +import at.hannibal2.skyhanni.events.BlockClickEvent +import at.hannibal2.skyhanni.events.ItemClickEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.features.rift.RiftAPI.isBlowgun +import at.hannibal2.skyhanni.features.rift.everywhere.EnigmaSoulWaypoints.soulLocations +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt +import at.hannibal2.skyhanni.utils.BlockUtils.getBlockStateAt +import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor +import at.hannibal2.skyhanni.utils.LocationUtils.canBeSeen +import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText +import at.hannibal2.skyhanni.utils.RenderUtils.drawWaypointFilled +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraft.block.BlockButtonWood +import net.minecraft.init.Blocks +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds + +@SkyHanniModule +object WoodenButtonsHelper { + + private val config get() = RiftAPI.config.enigmaSoulWaypoints + + private val patternGroup = RepoPattern.group("rift.area.dreadfarm.buttons") + + /** + * REGEX-TEST: §eYou have hit §r§b1/56 §r§eof the wooden buttons! + * REGEX-TEST: §eYou have hit §r§b10/56 §r§eof the wooden buttons! + */ + private val buttonHitPattern by patternGroup.pattern( + "hit", + "§eYou have hit §r§b\\d+/56 §r§eof the wooden buttons!", + ) + + private var buttonLocations = mapOf<String, List<LorenzVec>>() + private var hitButtons = mutableSetOf<LorenzVec>() + private var lastHitButton: LorenzVec? = null + private var currentSpot: GraphNode? = null + private var lastBlowgunFire = SimpleTimeMark.farPast() + + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + val data = event.getConstant<RiftWoodenButtonsJson>("rift/RiftWoodenButtons") + buttonLocations = mutableMapOf<String, List<LorenzVec>>().apply { + data.houses.forEach { (houseName, spots) -> + spots.forEach { spot -> + this["$houseName House:${spot.position}"] = spot.buttons + } + } + } + } + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + hitButtons.clear() + RiftAPI.allButtonsHit = false + currentSpot = null + } + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + findClosestSpot() + checkBlowgunActivatedButtons() + } + + private fun findClosestSpot() { + if (!showButtons()) return + val graph = IslandGraphs.currentIslandGraph ?: return + + val closestNode = graph.nodes + .filter { it.tags.contains(GraphNodeTag.RIFT_BUTTONS_QUEST) } + .filter { node -> + val spotName = "${node.name}:${node.position}" + val buttonsAtSpot = buttonLocations[spotName] ?: return@filter false + buttonsAtSpot.any { !hitButtons.contains(it) } + } + .minByOrNull { it.position.distanceToPlayer() } + + if (closestNode != currentSpot) { + currentSpot = closestNode + currentSpot?.let { + IslandGraphs.pathFind(it.position, "Button Spot", config.color.toChromaColor(), condition = { config.showPathFinder && config.showButtonsHelper }) + } + } + } + + @SubscribeEvent + fun onBlockClick(event: BlockClickEvent) { + if (!checkButtons()) return + + val location = event.position + if (location.getBlockAt() == Blocks.wooden_button && !hitButtons.contains(location)) { + lastHitButton = event.position + } + } + + @SubscribeEvent + fun onItemClick(event: ItemClickEvent) { + if (!checkButtons()) return + if (event.clickType != ClickType.RIGHT_CLICK) return + if (!event.itemInHand.isBlowgun) return + lastBlowgunFire = SimpleTimeMark.now() + } + + private fun checkBlowgunActivatedButtons() { + if (lastBlowgunFire.passedSince() > 2.5.seconds) return + buttonLocations.values.flatten().forEach { buttonLocation -> + val blockState = buttonLocation.getBlockStateAt() + if (blockState.block is BlockButtonWood && + blockState.getValue(BlockButtonWood.POWERED) == true && + buttonLocation.canBeSeen(1..3) && + lastHitButton != buttonLocation && + !hitButtons.contains(buttonLocation)) { + lastHitButton = buttonLocation + addLastHitButton() + } + } + } + + private fun addLastHitButton() { + if (lastHitButton !in hitButtons) { + lastHitButton?.let { hitButtons.add(it) } + } + } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!checkButtons()) return + + buttonHitPattern.matchMatcher(event.message) { + addLastHitButton() + } + + if (event.message != "§eYou've hit all §r§b56 §r§ewooden buttons!") return + RiftAPI.allButtonsHit = true + hitButtons = buttonLocations.values.flatten().toMutableSet() + soulLocations["Buttons"]?.let { + IslandGraphs.pathFind( + it, + "Buttons Enigma Soul", + config.color.toChromaColor(), + condition = { config.showPathFinder }, + ) + } + } + + @SubscribeEvent + fun onRenderWorld(event: LorenzRenderWorldEvent) { + if (!showButtons()) return + + val spot = currentSpot ?: return + val distance = spot.position.distanceToPlayer() + if (distance > 2.5) { + event.drawDynamicText(spot.position.add(y = 1), "Hit Buttons Here!", 1.25) + } + + if (distance > 15.0) return + val spotName = "${spot.name}:${spot.position}" + buttonLocations[spotName]?.forEach { button -> + if (!hitButtons.contains(button)) { + event.drawWaypointFilled(button, config.color.toChromaColor(), inverseAlphaScale = true) + } + } + } + + private fun checkButtons() = RiftAPI.inRift() && !RiftAPI.allButtonsHit + fun showButtons() = checkButtons() && RiftAPI.trackingButtons && config.showButtonsHelper +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveLivingMetalHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveLivingMetalHelper.kt index 3b64f0fb1..63a4e35cb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveLivingMetalHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveLivingMetalHelper.kt @@ -8,8 +8,8 @@ import at.hannibal2.skyhanni.events.ServerBlockChangeEvent import at.hannibal2.skyhanni.events.TitleReceivedEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer -import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.drawWaypointFilled import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -72,8 +72,8 @@ object LivingCaveLivingMetalHelper { } else b event.drawWaypointFilled( location, - LorenzColor.AQUA.toColor(), - seeThroughBlocks = location.distanceToPlayer() < 10 + color, + seeThroughBlocks = location.distanceToPlayer() < 10, ) } @@ -97,5 +97,7 @@ object LivingCaveLivingMetalHelper { } } + val color get() = config.color.get().toChromaColor() + fun isEnabled() = RiftAPI.inRift() && (RiftAPI.inLivingCave() || RiftAPI.inLivingStillness()) && config.enabled } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/RiftGunthersRace.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/RiftGunthersRace.kt new file mode 100644 index 000000000..cf729453f --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/RiftGunthersRace.kt @@ -0,0 +1,117 @@ +package at.hannibal2.skyhanni.features.rift.area.westvillage + +import at.hannibal2.skyhanni.data.jsonobjects.repo.ParkourJson +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.IslandChangeEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor +import at.hannibal2.skyhanni.utils.ConditionalUtils +import at.hannibal2.skyhanni.utils.ParkourHelper +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object RiftGunthersRace { + + private val config get() = RiftAPI.config.area.westVillage.gunthersRace + private var parkourHelper: ParkourHelper? = null + + private val patternGroup = RepoPattern.group("rift.area.westvillage.riftrace") + + /** + * REGEX-TEST: §3§lRIFT RACING §r§eRace started! Good luck! + */ + private val raceStartedPattern by patternGroup.pattern( + "start", + "§3§lRIFT RACING §r§eRace started! Good luck!" + ) + + /** + * REGEX-TEST: §3§lRIFT RACING §r§eRace finished in 00:36.539! + * REGEX-TEST: §3§lRIFT RACING §r§eRace finished in §r§300:32.794§r§e! §r§3§lPERSONAL BEST! + */ + private val raceFinishedPattern by patternGroup.pattern( + "finish", + "§3§lRIFT RACING §r§eRace finished in \\d+:\\d+.\\d+!.*" + ) + + /** + * REGEX-TEST: §3§lRIFT RACING §r§cRace cancelled! + * REGEX-TEST: §3§lRIFT RACING §r§cRace cancelled! Time limit reached! + * REGEX-TEST: §3§lRIFT RACING §r§cRace cancelled! You left the racing area! + */ + private val raceCancelledPattern by patternGroup.pattern( + "cancel", + "§3§lRIFT RACING §r§cRace cancelled!.*" + ) + + @SubscribeEvent + fun onIslandChange(event: IslandChangeEvent) { + parkourHelper?.reset() + } + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + RiftAPI.inRiftRace = false + } + + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + val data = event.getConstant<ParkourJson>("rift/RiftRace") + parkourHelper = ParkourHelper( + data.locations, + data.shortCuts, + detectionRange = 5.0, + goInOrder = true, + ) + updateConfig() + } + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + ConditionalUtils.onToggle(config.rainbowColor, config.monochromeColor, config.lookAhead) { + updateConfig() + } + } + + private fun updateConfig() { + parkourHelper?.run { + rainbowColor = config.rainbowColor.get() + monochromeColor = config.monochromeColor.get().toChromaColor() + lookAhead = config.lookAhead.get() + 1 + } + } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!isEnabled()) return + + raceStartedPattern.matchMatcher(event.message) { + RiftAPI.inRiftRace = true + } + raceCancelledPattern.matchMatcher(event.message) { + parkourHelper?.reset() + RiftAPI.inRiftRace = false + } + raceFinishedPattern.matchMatcher(event.message) { + parkourHelper?.reset() + RiftAPI.inRiftRace = false + } + } + + @SubscribeEvent + fun onRenderWorld(event: LorenzRenderWorldEvent) { + if (!isEnabled() || !RiftAPI.inRiftRace) return + + parkourHelper?.render(event) + } + + fun isEnabled() = + RiftAPI.inRift() && RiftAPI.inWestVillage() && config.enabled +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt index 3fa6af42f..c08594c26 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt @@ -11,7 +11,6 @@ import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture import at.hannibal2.skyhanni.utils.InventoryUtils -import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.TimeLimitedSet @@ -63,10 +62,8 @@ object VerminHighlighter { else -> false } - private fun inArea() = LorenzUtils.skyBlockArea.let { it == "West Village" || it == "Infested House" } - private fun hasItemInHand() = InventoryUtils.itemInHandId == "TURBOMAX_VACUUM".asInternalName() - fun isEnabled() = RiftAPI.inRift() && inArea() && config.enabled && hasItemInHand() + fun isEnabled() = RiftAPI.inRift() && RiftAPI.inWestVillage() && config.enabled && hasItemInHand() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt index e47fe8002..cedaa569b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt @@ -13,7 +13,6 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.addSearchString import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher @@ -162,9 +161,7 @@ object VerminTracker { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent) { if (!isEnabled()) return - if (!config.showOutsideWestVillage && - !LorenzUtils.skyBlockArea.let { it == "Infested House" || it == "West Village" } - ) return + if (!config.showOutsideWestVillage && !RiftAPI.inWestVillage()) return if (!config.showWithoutVacuum && !hasVacuum) return tracker.renderDisplay(config.position) diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt index 41ad12763..fc0856be6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.render.gui.ReplaceItemEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.features.rift.area.dreadfarm.WoodenButtonsHelper import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor @@ -36,7 +37,7 @@ object EnigmaSoulWaypoints { private val config get() = RiftAPI.config.enigmaSoulWaypoints private var inInventory = false - private var soulLocations = mapOf<String, LorenzVec>() + var soulLocations = mapOf<String, LorenzVec>() private val trackedSouls = mutableListOf<String>() private val inventoryUnfound = mutableListOf<String>() private var adding = true @@ -89,6 +90,9 @@ object EnigmaSoulWaypoints { if (event.slotId == 31 && inventoryUnfound.isNotEmpty()) { event.makePickblock() + if (inventoryUnfound.contains("Buttons")) { + RiftAPI.trackingButtons = !RiftAPI.trackingButtons + } if (adding) { trackedSouls.addAll(inventoryUnfound) adding = false @@ -107,12 +111,17 @@ object EnigmaSoulWaypoints { val name = split.last() if (!soulLocations.contains(name)) return + if (name == "Buttons") { + RiftAPI.trackingButtons = !RiftAPI.trackingButtons + } + if (!trackedSouls.contains(name)) { ChatUtils.chat("§5Tracking the $name Enigma Soul!", prefixColor = "§5") if (config.showPathFinder) { soulLocations[name]?.let { - - IslandGraphs.pathFind(it, "$name Enigma Soul", config.color.toChromaColor(), condition = { config.showPathFinder }) + if (!(name == "Buttons" && WoodenButtonsHelper.showButtons())) { + IslandGraphs.pathFind(it, "$name Enigma Soul", config.color.toChromaColor(), condition = { config.showPathFinder }) + } } } trackedSouls.add(name) @@ -189,6 +198,9 @@ object EnigmaSoulWaypoints { if (closestSoul in trackedSouls) { trackedSouls.remove(closestSoul) ChatUtils.chat("§5Found the $closestSoul Enigma Soul!", prefixColor = "§5") + if (closestSoul == "Buttons") { + RiftAPI.trackingButtons = false + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt index 403a78686..94fbe5c3e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt @@ -1,20 +1,22 @@ package at.hannibal2.skyhanni.features.rift.everywhere -import at.hannibal2.skyhanni.events.ActionBarUpdateEvent +import at.hannibal2.skyhanni.data.ActionBarStatsData +import at.hannibal2.skyhanni.events.ActionBarValueUpdateEvent import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.entity.EntityHealthDisplayEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.TimeUtils import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration import kotlin.time.Duration.Companion.minutes @@ -26,11 +28,6 @@ object RiftTimer { private val config get() = RiftAPI.config.timer private val repoGroup = RepoPattern.group("rift.everywhere") - private val timePattern by repoGroup.pattern( - "timer", - "§(?<color>[a7])(?<time>.*)ф Left.*" - ) - /** * REGEX-TEST: 3150 §aф */ @@ -53,23 +50,28 @@ object RiftTimer { currentTime = 0.seconds } - // todo use ActionBarValueUpdateEvent @SubscribeEvent - fun onActionBarUpdate(event: ActionBarUpdateEvent) { - if (!isEnabled()) return - - event.actionBar.split(" ").matchFirst(timePattern) { - val color = group("color") - val newTime = TimeUtils.getDuration(group("time").replace("m", "m ")) + fun onActionBarValueUpdate(event: ActionBarValueUpdateEvent) { + if (event.updated != ActionBarStatsData.RIFT_TIME) return + if (!isEnabled() || RiftAPI.inRiftRace) return - if (color == "7") { - if (newTime > maxTime) { - maxTime = newTime - } - } - currentTime = newTime - update() + val newTime = TimeUtils.getDuration(event.updated.value.replace("m", "m ")) + if (newTime > maxTime) { + maxTime = newTime } + currentTime = newTime + update() + } + + // prevents rift time from pausing during Rift Race + // (hypixel hides the action bar during the race) + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!isEnabled() || !RiftAPI.inRiftRace) return + if (!event.isMod(5)) return + val newTime = TimeUtils.getDuration(Minecraft.getMinecraft().thePlayer.experienceLevel.toString() + " s") + currentTime = newTime + update() } private fun update() { |