diff options
Diffstat (limited to 'src/main/kotlin/features/world')
-rw-r--r-- | src/main/kotlin/features/world/ColeWeightCompat.kt | 16 | ||||
-rw-r--r-- | src/main/kotlin/features/world/FairySouls.kt | 3 | ||||
-rw-r--r-- | src/main/kotlin/features/world/FirmWaypointManager.kt | 49 | ||||
-rw-r--r-- | src/main/kotlin/features/world/FirmWaypoints.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/features/world/TemporaryWaypoints.kt | 3 | ||||
-rw-r--r-- | src/main/kotlin/features/world/Waypoints.kt | 2 |
6 files changed, 58 insertions, 17 deletions
diff --git a/src/main/kotlin/features/world/ColeWeightCompat.kt b/src/main/kotlin/features/world/ColeWeightCompat.kt index b92a91e..f7f1317 100644 --- a/src/main/kotlin/features/world/ColeWeightCompat.kt +++ b/src/main/kotlin/features/world/ColeWeightCompat.kt @@ -16,9 +16,9 @@ import moe.nea.firmament.util.tr object ColeWeightCompat { @Serializable data class ColeWeightWaypoint( - val x: Int, - val y: Int, - val z: Int, + val x: Int?, + val y: Int?, + val z: Int?, val r: Int = 0, val g: Int = 0, val b: Int = 0, @@ -31,9 +31,9 @@ object ColeWeightCompat { } fun intoFirm(waypoints: List<ColeWeightWaypoint>, relativeTo: BlockPos): FirmWaypoints { - val w = waypoints.map { - FirmWaypoints.Waypoint(it.x + relativeTo.x, it.y + relativeTo.y, it.z + relativeTo.z) - } + val w = waypoints + .filter { it.x != null && it.y != null && it.z != null } + .map { FirmWaypoints.Waypoint(it.x!! + relativeTo.x, it.y!! + relativeTo.y, it.z!! + relativeTo.z) } return FirmWaypoints( "Imported Waypoints", "imported", @@ -101,8 +101,8 @@ object ColeWeightCompat { thenLiteral("importcw") { thenExecute { importAndInform(source, null) { - Text.stringifiedTranslatable("firmament.command.waypoint.import.cw", - it) + tr("firmament.command.waypoint.import.cw.success", + "Imported $it waypoints from ColeWeight.") } } } diff --git a/src/main/kotlin/features/world/FairySouls.kt b/src/main/kotlin/features/world/FairySouls.kt index 1263074..d4bf560 100644 --- a/src/main/kotlin/features/world/FairySouls.kt +++ b/src/main/kotlin/features/world/FairySouls.kt @@ -3,6 +3,7 @@ package moe.nea.firmament.features.world import io.github.moulberry.repo.data.Coordinate +import me.shedaniel.math.Color import kotlinx.serialization.Serializable import kotlinx.serialization.serializer import net.minecraft.text.Text @@ -100,7 +101,7 @@ object FairySouls : FirmamentFeature { if (!TConfig.displaySouls) return renderInWorld(it) { currentMissingSouls.forEach { - block(it.blockPos, 0x80FFFF00.toInt()) + block(it.blockPos, Color.ofRGBA(176, 0, 255, 128).color) } color(1f, 0f, 1f, 1f) currentLocationSouls.forEach { diff --git a/src/main/kotlin/features/world/FirmWaypointManager.kt b/src/main/kotlin/features/world/FirmWaypointManager.kt index 6b68a94..d18483c 100644 --- a/src/main/kotlin/features/world/FirmWaypointManager.kt +++ b/src/main/kotlin/features/world/FirmWaypointManager.kt @@ -1,11 +1,13 @@ package moe.nea.firmament.features.world +import com.mojang.brigadier.arguments.StringArgumentType import kotlinx.serialization.serializer import net.minecraft.text.Text import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.commands.DefaultSource import moe.nea.firmament.commands.RestArgumentType import moe.nea.firmament.commands.get +import moe.nea.firmament.commands.suggestsList import moe.nea.firmament.commands.thenArgument import moe.nea.firmament.commands.thenExecute import moe.nea.firmament.commands.thenLiteral @@ -45,23 +47,24 @@ object FirmWaypointManager { } fun loadWaypoints(waypoints: FirmWaypoints, sendFeedback: (Text) -> Unit) { - if (waypoints.isRelativeTo != null) { + val copy = waypoints.deepCopy() + if (copy.isRelativeTo != null) { val origin = MC.player!!.blockPos - waypoints.waypoints.replaceAll { + copy.waypoints.replaceAll { it.copy( x = it.x + origin.x, y = it.y + origin.y, z = it.z + origin.z, ) } - waypoints.lastRelativeImport = origin.toImmutable() + copy.lastRelativeImport = origin.toImmutable() sendFeedback(tr("firmament.command.waypoint.import.ordered.success", - "Imported ${waypoints.size} relative waypoints. Make sure you stand in the correct spot while loading the waypoints: ${waypoints.isRelativeTo}.")) + "Imported ${copy.size} relative waypoints. Make sure you stand in the correct spot while loading the waypoints: ${copy.isRelativeTo}.")) } else { sendFeedback(tr("firmament.command.waypoint.import.success", - "Imported ${waypoints.size} waypoints.")) + "Imported ${copy.size} waypoints.")) } - Waypoints.waypoints = waypoints + Waypoints.waypoints = copy } fun setOrigin(source: DefaultSource, text: String?) { @@ -95,6 +98,40 @@ object FirmWaypointManager { "Unset the origin of the waypoints. Run /firm waypoints export to save the waypoints with absolute coordinates.")) } } + thenLiteral("save") { + thenArgument("name", StringArgumentType.string()) { name -> + suggestsList { DataHolder.list().keys } + thenExecute { + val waypoints = Waypoints.useNonEmptyWaypoints() + if (waypoints == null) { + source.sendError(Waypoints.textNothingToExport()) + return@thenExecute + } + waypoints.id = get(name) + val exportableWaypoints = createExportableCopy(waypoints) + DataHolder.insert(get(name), exportableWaypoints) + DataHolder.save() + source.sendFeedback(tr("firmament.command.waypoint.saved", + "Saved waypoints locally as ${get(name)}. Use /firm waypoints load to load them again.")) + } + } + } + thenLiteral("load") { + thenArgument("name", StringArgumentType.string()) { name -> + suggestsList { DataHolder.list().keys } + thenExecute { + val name = get(name) + val waypoints = DataHolder.list()[name] + if (waypoints == null) { + source.sendError( + tr("firmament.command.waypoint.nosaved", + "No saved waypoint for ${name}. Use tab completion to see available names.")) + return@thenExecute + } + loadWaypoints(waypoints, source::sendFeedback) + } + } + } thenLiteral("export") { thenExecute { val waypoints = Waypoints.useNonEmptyWaypoints() diff --git a/src/main/kotlin/features/world/FirmWaypoints.kt b/src/main/kotlin/features/world/FirmWaypoints.kt index d149501..d0cd55a 100644 --- a/src/main/kotlin/features/world/FirmWaypoints.kt +++ b/src/main/kotlin/features/world/FirmWaypoints.kt @@ -16,6 +16,8 @@ data class FirmWaypoints( var isOrdered: Boolean, // TODO: val resetOnSwap: Boolean, ) { + + fun deepCopy() = copy(waypoints = waypoints.toMutableList()) @Transient var lastRelativeImport: BlockPos? = null diff --git a/src/main/kotlin/features/world/TemporaryWaypoints.kt b/src/main/kotlin/features/world/TemporaryWaypoints.kt index b36c49d..3c8e895 100644 --- a/src/main/kotlin/features/world/TemporaryWaypoints.kt +++ b/src/main/kotlin/features/world/TemporaryWaypoints.kt @@ -1,5 +1,6 @@ package moe.nea.firmament.features.world +import me.shedaniel.math.Color import kotlin.compareTo import kotlin.text.clear import kotlin.time.Duration.Companion.seconds @@ -38,7 +39,7 @@ object TemporaryWaypoints { if (temporaryPlayerWaypointList.isEmpty()) return RenderInWorldContext.renderInWorld(event) { temporaryPlayerWaypointList.forEach { (_, waypoint) -> - block(waypoint.pos, 0xFFFFFF00.toInt()) + block(waypoint.pos, Color.ofRGBA(255, 255, 0, 128).color) } temporaryPlayerWaypointList.forEach { (player, waypoint) -> val skin = diff --git a/src/main/kotlin/features/world/Waypoints.kt b/src/main/kotlin/features/world/Waypoints.kt index b5c2b66..b4f91b0 100644 --- a/src/main/kotlin/features/world/Waypoints.kt +++ b/src/main/kotlin/features/world/Waypoints.kt @@ -45,7 +45,7 @@ object Waypoints : FirmamentFeature { RenderInWorldContext.renderInWorld(event) { if (!w.isOrdered) { w.waypoints.withIndex().forEach { - block(it.value.blockPos, 0x800050A0.toInt()) + block(it.value.blockPos, Color.ofRGBA(0, 80, 160, 128).color) if (TConfig.showIndex) withFacingThePlayer(it.value.blockPos.toCenterPos()) { text(Text.literal(it.index.toString())) } |