diff options
author | Linnea Gräf <nea@nea.moe> | 2024-05-07 13:39:20 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-05-07 13:39:20 +0200 |
commit | 2ab7f403b38690614b7ac27f5e6ac60b991c0375 (patch) | |
tree | aba449aed93ff09defdc5f51194777f6f7e5b763 /src | |
parent | 986929941451d5bb6b9e6f245489f20963438614 (diff) | |
download | Firmament-2ab7f403b38690614b7ac27f5e6ac60b991c0375.tar.gz Firmament-2ab7f403b38690614b7ac27f5e6ac60b991c0375.tar.bz2 Firmament-2ab7f403b38690614b7ac27f5e6ac60b991c0375.zip |
Add remove command to waypoints
Diffstat (limited to 'src')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/features/world/Waypoints.kt | 44 | ||||
-rw-r--r-- | src/main/resources/assets/firmament/lang/en_us.json | 5 |
2 files changed, 42 insertions, 7 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 279be6f..5d75731 100644 --- a/src/main/kotlin/moe/nea/firmament/features/world/Waypoints.kt +++ b/src/main/kotlin/moe/nea/firmament/features/world/Waypoints.kt @@ -7,10 +7,10 @@ package moe.nea.firmament.features.world +import com.mojang.brigadier.arguments.IntegerArgumentType import me.shedaniel.math.Color import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource import kotlinx.serialization.Serializable -import kotlinx.serialization.decodeFromString import kotlin.collections.component1 import kotlin.collections.component2 import kotlin.collections.set @@ -22,6 +22,7 @@ import net.minecraft.text.Text import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Vec3d import moe.nea.firmament.Firmament +import moe.nea.firmament.commands.get import moe.nea.firmament.commands.thenArgument import moe.nea.firmament.commands.thenExecute import moe.nea.firmament.commands.thenLiteral @@ -43,6 +44,10 @@ 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 } + // TODO: look ahead size + // TODO: skip to nearest/skip to next only + // TODO: skip command } data class TemporaryWaypoint( @@ -143,6 +148,21 @@ object Waypoints : FirmamentFeature { source.sendFeedback(Text.translatable("firmament.command.waypoint.ordered.toggle.$ordered")) } } + thenLiteral("remove") { + thenArgument("index", IntegerArgumentType.integer(0)) { indexArg -> + thenExecute { + val index = get(indexArg) + if (index in waypoints.indices) { + waypoints.removeAt(index) + source.sendFeedback(Text.stringifiedTranslatable( + "firmament.command.waypoint.remove", + index)) + } else { + source.sendError(Text.stringifiedTranslatable("firmament.command.waypoint.remove.error")) + } + } + } + } thenLiteral("import") { thenExecute { val contents = ClipboardUtils.getTextContents() @@ -169,16 +189,22 @@ object Waypoints : FirmamentFeature { if (waypoints.isEmpty()) return@subscribe RenderInWorldContext.renderInWorld(event) { if (!ordered) { - color(0f, 0.3f, 0.7f, 0.5f) - waypoints.forEach { - block(it) + waypoints.withIndex().forEach { + color(0f, 0.3f, 0.7f, 0.5f) + block(it.value) + color(1f, 1f, 1f, 1f) + if (TConfig.showIndex) + withFacingThePlayer(it.value.toCenterPos()) { + text(Text.literal(it.index.toString())) + } } } else { orderedIndex %= waypoints.size val firstColor = Color.ofRGBA(0, 200, 40, 180) color(firstColor) tracer(waypoints[orderedIndex].toCenterPos(), lineWidth = 3f) - waypoints.wrappingWindow(orderedIndex, 3) + waypoints.withIndex().toList() + .wrappingWindow(orderedIndex, 3) .zip( listOf( firstColor, @@ -187,9 +213,15 @@ object Waypoints : FirmamentFeature { ) ) .reversed() - .forEach { (pos, col) -> + .forEach { (waypoint, col) -> + val (index, pos) = waypoint color(col) block(pos) + color(1f, 1f, 1f, 1f) + if (TConfig.showIndex) + withFacingThePlayer(pos.toCenterPos()) { + text(Text.literal(index.toString())) + } } } } diff --git a/src/main/resources/assets/firmament/lang/en_us.json b/src/main/resources/assets/firmament/lang/en_us.json index 05cc8ea..dca98eb 100644 --- a/src/main/resources/assets/firmament/lang/en_us.json +++ b/src/main/resources/assets/firmament/lang/en_us.json @@ -6,9 +6,11 @@ "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.clear": "Cleared waypoints.", "firmament.command.waypoint.added": "Added waypoint %s %s %s.", - "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.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.pristine-profit.collection": "Collection: %s/h", "firmament.pristine-profit.money": "Money: %s/h", "firmament.toggle.true": "On", @@ -83,6 +85,7 @@ "firmament.waypoint.temporary": "Temporary Waypoint: %s", "firmament.config.waypoints": "Waypoints", "firmament.config.waypoints.temp-waypoint-duration": "Temporary Waypoint Duration", + "firmament.config.waypoints.show-index": "Show ordered waypoint indexes", "firmament.recipe.forge.time": "Forging Time: %s", "firmament.recipe.mobs.drops": "§e§lDrop Chance: %s", "firmament.recipe.mobs.name": "§8[§7Lv %d§8] §c%s", |