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 | |
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')
18 files changed, 461 insertions, 52 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index b9f21ca22..aa15461f5 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt @@ -12,7 +12,7 @@ import com.google.gson.JsonPrimitive object ConfigUpdaterMigrator { val logger = LorenzLogger("ConfigMigration") - const val CONFIG_VERSION = 59 + const val CONFIG_VERSION = 60 fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? { if (chain.isEmpty()) return this if (this !is JsonObject) return null diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/rift/EnigmaSoulConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/rift/EnigmaSoulConfig.java index f64a42506..69a87bd31 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/rift/EnigmaSoulConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/rift/EnigmaSoulConfig.java @@ -32,4 +32,9 @@ public class EnigmaSoulConfig { @ConfigOption(name = "Color", desc = "Color of the Enigma Souls.") @ConfigEditorColour public String color = "0:245:219:27:198"; + + @Expose + @ConfigOption(name = "Buttons Helper", desc = "Help find all 56 wooden buttons required for the Buttons soul when tracking it.") + @ConfigEditorBoolean + public boolean showButtonsHelper = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/dreadfarm/WiltedBerberisConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/dreadfarm/WiltedBerberisConfig.java index eddcb740d..2aa89f66e 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/dreadfarm/WiltedBerberisConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/dreadfarm/WiltedBerberisConfig.java @@ -21,7 +21,10 @@ public class WiltedBerberisConfig { @Expose @ConfigOption(name = "Hide Particles", desc = "Hide the Wilted Berberis particles.") @ConfigEditorBoolean - // TODO fix typo - public boolean hideparticles = false; + public boolean hideParticles = false; + @Expose + @ConfigOption(name = "Mute Others Sounds", desc = "Mute nearby Wilted Berberis sounds while not holding a Wand of Farming or not standing on Farmland blocks.") + @ConfigEditorBoolean + public boolean muteOthersSounds = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/livingcave/LivingCaveLivingMetalConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/livingcave/LivingCaveLivingMetalConfig.java index 38f60870f..4053070e3 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/livingcave/LivingCaveLivingMetalConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/livingcave/LivingCaveLivingMetalConfig.java @@ -3,7 +3,9 @@ package at.hannibal2.skyhanni.config.features.rift.area.livingcave; import at.hannibal2.skyhanni.config.FeatureToggle; import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorColour; import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; +import io.github.notenoughupdates.moulconfig.observer.Property; public class LivingCaveLivingMetalConfig { @@ -19,4 +21,9 @@ public class LivingCaveLivingMetalConfig { @FeatureToggle public boolean hideParticles = false; + @Expose + @ConfigOption(name = "Color", desc = "Set the color to highlight the blocks in.") + @ConfigEditorColour + public Property<String> color = Property.of("0:255:85:255:255"); + } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/GunthersRaceConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/GunthersRaceConfig.java new file mode 100644 index 000000000..beb4acc9e --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/GunthersRaceConfig.java @@ -0,0 +1,33 @@ +package at.hannibal2.skyhanni.config.features.rift.area.westvillage; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorColour; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider; +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; +import io.github.notenoughupdates.moulconfig.observer.Property; + +public class GunthersRaceConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Show the route for Gunther's rift race.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = true; + + @Expose + @ConfigOption(name = "Look Ahead", desc = "Change how many waypoints should be shown in front of you.") + @ConfigEditorSlider(minStep = 1, maxValue = 30, minValue = 1) + public Property<Integer> lookAhead = Property.of(3); + + @Expose + @ConfigOption(name = "Rainbow Color", desc = "Show the rainbow color effect instead of a boring monochrome.") + @ConfigEditorBoolean + public Property<Boolean> rainbowColor = Property.of(true); + + @Expose + @ConfigOption(name = "Monochrome Color", desc = "Set a boring monochrome color for the guide waypoints.") + @ConfigEditorColour + public Property<String> monochromeColor = Property.of("0:60:0:0:255"); +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/WestVillageConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/WestVillageConfig.java index 5dbf1a231..fa6db5214 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/WestVillageConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/WestVillageConfig.java @@ -6,11 +6,6 @@ import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; public class WestVillageConfig { - @ConfigOption(name = "Kloon Hacking", desc = "") - @Accordion - @Expose - public KloonHackingConfig hacking = new KloonHackingConfig(); - @ConfigOption(name = "Vermin Tracker", desc = "Track all vermins collected.") @Accordion @Expose @@ -20,4 +15,14 @@ public class WestVillageConfig { @Accordion @Expose public VerminHighlightConfig verminHighlight = new VerminHighlightConfig(); + + @ConfigOption(name = "Gunther's Race", desc = "") + @Accordion + @Expose + public GunthersRaceConfig gunthersRace = new GunthersRaceConfig(); + + @ConfigOption(name = "Kloon Hacking", desc = "") + @Accordion + @Expose + public KloonHackingConfig hacking = new KloonHackingConfig(); } diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/RiftWoodenButtonsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/RiftWoodenButtonsJson.kt new file mode 100644 index 000000000..fdc4befe7 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/RiftWoodenButtonsJson.kt @@ -0,0 +1,13 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import at.hannibal2.skyhanni.utils.LorenzVec +import com.google.gson.annotations.Expose + +data class RiftWoodenButtonsJson( + @Expose val houses: Map<String, List<ButtonSpots>> +) + +data class ButtonSpots( + @Expose val position: LorenzVec, + @Expose val buttons: List<LorenzVec> +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/model/GraphNodeTag.kt b/src/main/java/at/hannibal2/skyhanni/data/model/GraphNodeTag.kt index 6bf00edaf..8efcf4621 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/model/GraphNodeTag.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/model/GraphNodeTag.kt @@ -42,6 +42,7 @@ enum class GraphNodeTag( // Rift RIFT_ENIGMA("rift_enigma", LorenzColor.DARK_PURPLE, "Enigma Soul", "Enigma Souls in the Rift.", onlyIsland = IslandType.THE_RIFT), + RIFT_BUTTONS_QUEST("rift_buttons_quest", LorenzColor.LIGHT_PURPLE, "Wooden Buttons", "A spot to hit wooden buttons for the Dreadfarm Enigma Soul.", onlyIsland = IslandType.THE_RIFT), RIFT_EYE("rift_eye", LorenzColor.DARK_RED, "Rift Eye", "An Eye in the Rift to teleport to.", onlyIsland = IslandType.THE_RIFT), RIFT_MONTEZUMA( "rift_montezuma", 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() { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt b/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt index cf01b2bf9..4fccbed68 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt @@ -23,6 +23,7 @@ class ParkourHelper( val detectionRange: Double = 1.0, val depth: Boolean = true, val onEndReach: () -> Unit = {}, + val goInOrder: Boolean = false, ) { private var current = -1 @@ -58,9 +59,9 @@ class ParkourHelper( for ((index, location) in locations.withIndex()) { val onGround = Minecraft.getMinecraft().thePlayer.onGround val closeEnough = location.offsetCenter().distanceToPlayer() < detectionRange - if (closeEnough && onGround) { - current = index - } + if (!(closeEnough && onGround)) continue + if (goInOrder && (index < current - 1 || index > current + 1)) continue + current = index } } |