aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-05-07 19:05:55 +0200
committerLinnea Gräf <nea@nea.moe>2024-05-07 19:05:55 +0200
commit0cb976ce078b9b0217c9a8e5763638764d89a31e (patch)
tree3a746b120b0dcf38276fc7f945f1ac0ba14c350d
parentd47a3e8633fbeca3ef4e733a1238ef38b7a5c6e6 (diff)
downloadFirmament-0cb976ce078b9b0217c9a8e5763638764d89a31e.tar.gz
Firmament-0cb976ce078b9b0217c9a8e5763638764d89a31e.tar.bz2
Firmament-0cb976ce078b9b0217c9a8e5763638764d89a31e.zip
Add skipping ordered waypoints
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/world/Waypoints.kt22
-rw-r--r--src/main/resources/assets/firmament/lang/en_us.json4
2 files changed, 21 insertions, 5 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/features/world/Waypoints.kt b/src/main/kotlin/moe/nea/firmament/features/world/Waypoints.kt
index b41c31a..bad82b0 100644
--- a/src/main/kotlin/moe/nea/firmament/features/world/Waypoints.kt
+++ b/src/main/kotlin/moe/nea/firmament/features/world/Waypoints.kt
@@ -45,9 +45,8 @@ object Waypoints : FirmamentFeature {
object TConfig : ManagedConfig(identifier) {
val tempWaypointDuration by duration("temp-waypoint-duration", 0.seconds, 1.hours) { 30.seconds }
val showIndex by toggle("show-index") { true }
+ val skipToNearest by toggle("skip-to-nearest") { false }
// TODO: look ahead size
- // TODO: skip to nearest/skip to next only
- // TODO: skip command
}
data class TemporaryWaypoint(
@@ -148,6 +147,16 @@ object Waypoints : FirmamentFeature {
source.sendFeedback(Text.translatable("firmament.command.waypoint.ordered.toggle.$ordered"))
}
}
+ thenLiteral("skip") {
+ thenExecute {
+ if (ordered && waypoints.isNotEmpty()) {
+ orderedIndex = (orderedIndex + 1) % waypoints.size
+ source.sendFeedback(Text.translatable("firmament.command.waypoint.skip"))
+ } else {
+ source.sendError(Text.translatable("firmament.command.waypoint.skip.error"))
+ }
+ }
+ }
thenLiteral("remove") {
thenArgument("index", IntegerArgumentType.integer(0)) { indexArg ->
thenExecute {
@@ -230,8 +239,13 @@ object Waypoints : FirmamentFeature {
if (waypoints.isEmpty() || !ordered) return@subscribe
orderedIndex %= waypoints.size
val p = MC.player?.pos ?: return@subscribe
- if (waypoints[orderedIndex].isWithinDistance(p, 3.0)) {
- orderedIndex = (orderedIndex + 1) % waypoints.size
+ if (TConfig.skipToNearest) {
+ orderedIndex =
+ (waypoints.withIndex().minBy { it.value.getSquaredDistance(p) }.index + 1) % waypoints.size
+ } else {
+ if (waypoints[orderedIndex].isWithinDistance(p, 3.0)) {
+ orderedIndex = (orderedIndex + 1) % waypoints.size
+ }
}
}
ProcessChatEvent.subscribe {
diff --git a/src/main/resources/assets/firmament/lang/en_us.json b/src/main/resources/assets/firmament/lang/en_us.json
index dca98eb..b5615c4 100644
--- a/src/main/resources/assets/firmament/lang/en_us.json
+++ b/src/main/resources/assets/firmament/lang/en_us.json
@@ -6,11 +6,13 @@
"firmament.command.toggle.not-a-toggle": "Property %s is not a toggle",
"firmament.command.toggle.toggled": "Toggled %s / %s %s",
"firmament.command.waypoint.import": "Imported %s waypoints from clipboard.",
- "firmament.command.waypoint.import.error": "Could not import waypoints. Make sure they are on ColeWeight format:\n[{\"x\": 69, \"y\":420, \"z\": 36}]",
+ "firmament.command.waypoint.import.error": "Could not import waypoints from clipboard. Make sure they are on ColeWeight format:\n[{\"x\": 69, \"y\":420, \"z\": 36}]",
"firmament.command.waypoint.clear": "Cleared waypoints.",
"firmament.command.waypoint.added": "Added waypoint %s %s %s.",
"firmament.command.waypoint.remove": "Removed waypoint %s. Other waypoints may have different indexes now.",
"firmament.command.waypoint.remove.error": "Could not find waypoint with that index to delete.",
+ "firmament.command.waypoint.skip.error": "Could not skip a waypoint. Are you in ordered waypoint mode with waypoints loaded?",
+ "firmament.command.waypoint.skip": "Skipped 1 waypoint",
"firmament.pristine-profit.collection": "Collection: %s/h",
"firmament.pristine-profit.money": "Money: %s/h",
"firmament.toggle.true": "On",