aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/event
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-09-13 20:23:57 +0200
committerGitHub <noreply@github.com>2024-09-13 20:23:57 +0200
commit5e01624dcc315a2bf7665fc808b1113fa4c9e0d8 (patch)
tree6a97c6970fecd2d517eac80c1aa391eee42addd2 /src/main/java/at/hannibal2/skyhanni/features/event
parent691d2551cf722b76c1894c814d1f6c2e98fe17d6 (diff)
downloadskyhanni-5e01624dcc315a2bf7665fc808b1113fa4c9e0d8.tar.gz
skyhanni-5e01624dcc315a2bf7665fc808b1113fa4c9e0d8.tar.bz2
skyhanni-5e01624dcc315a2bf7665fc808b1113fa4c9e0d8.zip
Feature: Graphs Pathfinding (#2468)
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/diana/GriffinBurrowHelper.kt32
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocations.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt46
3 files changed, 54 insertions, 26 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt
index 35a783f7d..aa58c3c0f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt
@@ -49,17 +49,16 @@ object GriffinBurrowHelper {
private val config get() = SkyHanniMod.feature.event.diana
- private val allowedBlocksAboveGround =
- listOf(
- Blocks.air,
- Blocks.leaves,
- Blocks.leaves2,
- Blocks.tallgrass,
- Blocks.double_plant,
- Blocks.red_flower,
- Blocks.yellow_flower,
- Blocks.spruce_fence
- )
+ private val allowedBlocksAboveGround = listOf(
+ Blocks.air,
+ Blocks.leaves,
+ Blocks.leaves2,
+ Blocks.tallgrass,
+ Blocks.double_plant,
+ Blocks.red_flower,
+ Blocks.yellow_flower,
+ Blocks.spruce_fence,
+ )
var targetLocation: LorenzVec? = null
private var guessLocation: LorenzVec? = null
@@ -134,7 +133,14 @@ object GriffinBurrowHelper {
}
locations.addAll(InquisitorWaypointShare.waypoints.values.map { it.location })
}
- targetLocation = locations.minByOrNull { it.distanceToPlayer() }
+ val newLocation = locations.minByOrNull { it.distanceToPlayer() }
+ if (targetLocation != newLocation) {
+ targetLocation = newLocation
+ // add island graphs here some day when the hub is fully added in the graph
+// newLocation?.let {
+// IslandGraphs.find(it)
+// }
+ }
if (config.burrowNearestWarp) {
targetLocation?.let {
@@ -401,7 +407,7 @@ object GriffinBurrowHelper {
if (currentMayor != Mayor.DIANA) {
ChatUtils.chatAndOpenConfig(
"§cSelect Diana as mayor overwrite!",
- SkyHanniMod.feature.dev.debug::assumeMayor
+ SkyHanniMod.feature.dev.debug::assumeMayor,
)
} else {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocations.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocations.kt
index cce0aef79..896220842 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocations.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocations.kt
@@ -30,7 +30,7 @@ object HoppityEggLocations {
ChocolateFactoryAPI.profileStorage?.collectedEggLocations = value
}
- private var apiEggLocations: Map<IslandType, Map<String, LorenzVec>> = mapOf()
+ var apiEggLocations: Map<IslandType, Map<String, LorenzVec>> = mapOf()
val islandLocations
get() = apiEggLocations[LorenzUtils.skyBlockIsland]?.values?.toSet() ?: emptySet()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt
index d15d43d81..0d5bfefa8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.event.hoppity
import at.hannibal2.skyhanni.data.ClickType
+import at.hannibal2.skyhanni.data.IslandGraphs
import at.hannibal2.skyhanni.events.DebugDataCollectEvent
import at.hannibal2.skyhanni.events.ItemClickEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
@@ -19,6 +20,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
+import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
import at.hannibal2.skyhanni.utils.RecalculatingValue
import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine
import at.hannibal2.skyhanni.utils.RenderUtils.drawColor
@@ -154,8 +156,7 @@ object HoppityEggLocator {
}
private fun LorenzRenderWorldEvent.drawEggWaypoint(location: LorenzVec, label: String) {
- val shouldMarkDuplicate = config.highlightDuplicateEggLocations
- && HoppityEggLocations.hasCollectedEgg(location)
+ val shouldMarkDuplicate = config.highlightDuplicateEggLocations && HoppityEggLocations.hasCollectedEgg(location)
val possibleDuplicateLabel = if (shouldMarkDuplicate) "$label §c(Duplicate Location)" else label
if (!shouldMarkDuplicate) {
drawWaypointFilled(location, config.waypointColor.toChromaColor(), seeThroughBlocks = true)
@@ -165,8 +166,7 @@ object HoppityEggLocator {
drawDynamicText(location.add(y = 1), possibleDuplicateLabel, 1.5)
}
- private fun shouldShowAllEggs() =
- config.showAllWaypoints && !locatorInHotbar && HoppityEggType.eggsRemaining()
+ private fun shouldShowAllEggs() = config.showAllWaypoints && !locatorInHotbar && HoppityEggType.eggsRemaining()
fun eggFound() {
resetData()
@@ -214,6 +214,7 @@ object HoppityEggLocator {
if (event.clickType == ClickType.RIGHT_CLICK && item.isLocatorItem) {
lastClick = SimpleTimeMark.now()
MythicRabbitPetWarning.check()
+ trySendingGraph()
}
}
@@ -264,20 +265,29 @@ object HoppityEggLocator {
possibleEggLocations = filteredEggs
+ if (drawLocations) return
drawLocations = true
+
+ trySendingGraph()
+ }
+
+ private fun trySendingGraph() {
+ if (!config.showPathFinder) return
+ val location = possibleEggLocations.firstOrNull() ?: return
+
+ val color = config.waypointColor.toChromaColor()
+
+ IslandGraphs.pathFind(location, color, condition = { config.showPathFinder })
}
- fun isValidEggLocation(location: LorenzVec): Boolean =
- HoppityEggLocations.islandLocations.any { it.distance(location) < 5.0 }
+ fun isValidEggLocation(location: LorenzVec): Boolean = HoppityEggLocations.islandLocations.any { it.distance(location) < 5.0 }
- private fun ReceiveParticleEvent.isVillagerParticle() =
- type == EnumParticleTypes.VILLAGER_HAPPY && speed == 0.0f && count == 1
+ private fun ReceiveParticleEvent.isVillagerParticle() = type == EnumParticleTypes.VILLAGER_HAPPY && speed == 0.0f && count == 1
- private fun ReceiveParticleEvent.isEnchantmentParticle() =
- type == EnumParticleTypes.ENCHANTMENT_TABLE && speed == -2.0f && count == 10
+ private fun ReceiveParticleEvent.isEnchantmentParticle() = type == EnumParticleTypes.ENCHANTMENT_TABLE && speed == -2.0f && count == 10
- fun isEnabled() = LorenzUtils.inSkyBlock && config.waypoints && !GardenAPI.inGarden() &&
- !ReminderUtils.isBusy(true) && HoppityAPI.isHoppityEvent()
+ fun isEnabled() =
+ LorenzUtils.inSkyBlock && config.waypoints && !GardenAPI.inGarden() && !ReminderUtils.isBusy(true) && HoppityAPI.isHoppityEvent()
private val ItemStack.isLocatorItem get() = getInternalName() == locatorItem
@@ -314,4 +324,16 @@ object HoppityEggLocator {
add("Current Egg Note: ${currentEggNote ?: "None"}")
}
}
+
+ fun testPathfind(args: Array<String>) {
+ val target = args[0].formatInt()
+ HoppityEggLocations.apiEggLocations[LorenzUtils.skyBlockIsland]?.let {
+ for ((i, location) in it.values.withIndex()) {
+ if (i == target) {
+ IslandGraphs.pathFind(location)
+ return
+ }
+ }
+ }
+ }
}