aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-03-17 21:20:46 +0100
committerLinnea Gräf <nea@nea.moe>2025-03-17 21:20:46 +0100
commit16cc3b2a7cf9ccb3a5c06e379d7272ddfa310bbe (patch)
tree56446f5c516f8c17382727d04042ae4aaadb2f83
parent03cf4e465cf6b3412f3c0990cb642bf5db264b4c (diff)
downloadFirmament-16cc3b2a7cf9ccb3a5c06e379d7272ddfa310bbe.tar.gz
Firmament-16cc3b2a7cf9ccb3a5c06e379d7272ddfa310bbe.tar.bz2
Firmament-16cc3b2a7cf9ccb3a5c06e379d7272ddfa310bbe.zip
feat: Add relative waypoints to import coords relative to a structure
-rw-r--r--src/main/kotlin/features/world/Waypoints.kt58
-rw-r--r--src/test/resources/testdata/items/necron-boots.snbt68
-rw-r--r--translations/en_us.json2
3 files changed, 113 insertions, 15 deletions
diff --git a/src/main/kotlin/features/world/Waypoints.kt b/src/main/kotlin/features/world/Waypoints.kt
index 3ebfe70..2e4cb70 100644
--- a/src/main/kotlin/features/world/Waypoints.kt
+++ b/src/main/kotlin/features/world/Waypoints.kt
@@ -208,30 +208,58 @@ object Waypoints : FirmamentFeature {
it.z)
})
ClipboardUtils.setTextContent(data)
- source.sendFeedback(tr("firmament.command.waypoint.export", "Copied ${waypoints.size} waypoints to clipboard"))
+ source.sendFeedback(tr("firmament.command.waypoint.export",
+ "Copied ${waypoints.size} waypoints to clipboard"))
+ }
+ }
+ thenLiteral("exportrelative") {
+ thenExecute {
+ val playerPos = MC.player!!.blockPos
+ val x = playerPos.x
+ val y = playerPos.y
+ val z = playerPos.z
+ val data = Firmament.tightJson.encodeToString<List<ColeWeightWaypoint>>(waypoints.map {
+ ColeWeightWaypoint(it.x - x,
+ it.y - y,
+ it.z - z)
+ })
+ ClipboardUtils.setTextContent(data)
+ source.sendFeedback(tr("firmament.command.waypoint.export.relative",
+ "Copied ${waypoints.size} relative waypoints to clipboard. Make sure to stand in the same position when importing."))
+
}
}
thenLiteral("import") {
thenExecute {
- val contents = ClipboardUtils.getTextContents()
- val data = try {
- Firmament.tightJson.decodeFromString<List<ColeWeightWaypoint>>(contents)
- } catch (ex: Exception) {
- Firmament.logger.error("Could not load waypoints from clipboard", ex)
- source.sendError(Text.translatable("firmament.command.waypoint.import.error"))
- return@thenExecute
- }
- waypoints.clear()
- data.mapTo(waypoints) { BlockPos(it.x, it.y, it.z) }
source.sendFeedback(
- Text.stringifiedTranslatable(
- "firmament.command.waypoint.import",
- data.size
- )
+ importRelative(BlockPos.ORIGIN)
+ ?: Text.stringifiedTranslatable("firmament.command.waypoint.import", waypoints.size),
)
}
}
+ thenLiteral("importrelative") {
+ thenExecute {
+ source.sendFeedback(
+ importRelative(MC.player!!.blockPos)
+ ?: tr("firmament.command.waypoint.import.relative",
+ "Imported ${waypoints.size} relative waypoints from clipboard. Make sure you stand in the same position as when you exported these waypoints for them to line up correctly."),
+ )
+ }
+ }
+ }
+ }
+
+ fun importRelative(pos: BlockPos): Text? {
+ val contents = ClipboardUtils.getTextContents()
+ val data = try {
+ Firmament.tightJson.decodeFromString<List<ColeWeightWaypoint>>(contents)
+ } catch (ex: Exception) {
+ Firmament.logger.error("Could not load waypoints from clipboard", ex)
+ return (Text.translatable("firmament.command.waypoint.import.error"))
}
+ waypoints.clear()
+ data.mapTo(waypoints) { BlockPos(it.x + pos.x, it.y + pos.y, it.z + pos.z) }
+ return null
}
@Subscribe
diff --git a/src/test/resources/testdata/items/necron-boots.snbt b/src/test/resources/testdata/items/necron-boots.snbt
new file mode 100644
index 0000000..35f8cf0
--- /dev/null
+++ b/src/test/resources/testdata/items/necron-boots.snbt
@@ -0,0 +1,68 @@
+{
+ components: {
+ "minecraft:attribute_modifiers": {
+ modifiers: [
+ ],
+ show_in_tooltip: 0b
+ },
+ "minecraft:custom_data": {
+ enchantments: {
+ depth_strider: 3,
+ feather_falling: 10,
+ growth: 5,
+ protection: 5
+ },
+ id: "POWER_WITHER_BOOTS",
+ modifier: "ancient",
+ rarity_upgrades: 1,
+ timestamp: 1704550620000L,
+ upgrade_level: 5,
+ uuid: "8b6c7485-cb59-44d3-ac8f-9e52a611cc64"
+ },
+ "minecraft:custom_name": '{"extra":[{"color":"light_purple","text":"Ancient Necron\'s Boots "},{"color":"gold","text":"✪✪✪✪✪"}],"italic":false,"text":""}',
+ "minecraft:dyed_color": {
+ rgb: 15167036,
+ show_in_tooltip: 0b
+ },
+ "minecraft:enchantments": {
+ levels: {
+ "minecraft:depth_strider": 3
+ }
+ },
+ "minecraft:hide_additional_tooltip": {
+ },
+ "minecraft:lore": [
+ '{"extra":[{"color":"gray","text":"Gear Score: "},{"color":"light_purple","text":"713 "},{"color":"dark_gray","text":"(2753)"}],"italic":false,"text":""}',
+ '{"extra":[{"color":"gray","text":"Strength: "},{"color":"red","text":"+79 "},{"color":"blue","text":"(+35) "},{"color":"dark_gray","text":"(+333.75)"}],"italic":false,"text":""}',
+ '{"extra":[{"color":"gray","text":"Crit Chance: "},{"color":"red","text":"+15% "},{"color":"blue","text":"(+15%) "},{"color":"dark_gray","text":"(+23.1%)"}],"italic":false,"text":""}',
+ '{"extra":[{"color":"gray","text":"Crit Damage: "},{"color":"red","text":"+71% "},{"color":"blue","text":"(+38%) "},{"color":"dark_gray","text":"(+302.6%)"}],"italic":false,"text":""}',
+ '{"extra":[{"color":"gray","text":"Health: "},{"color":"green","text":"+241.5 "},{"color":"blue","text":"(+7) "},{"color":"dark_gray","text":"(+1,010.15)"}],"italic":false,"text":""}',
+ '{"extra":[{"color":"gray","text":"Defense: "},{"color":"green","text":"+120.5 "},{"color":"blue","text":"(+7) "},{"color":"dark_gray","text":"(+498.4)"}],"italic":false,"text":""}',
+ '{"extra":[{"color":"gray","text":"Intelligence: "},{"color":"green","text":"+36 "},{"color":"blue","text":"(+25) "},{"color":"dark_gray","text":"(+155.75)"}],"italic":false,"text":""}',
+ '{"extra":[" ",{"color":"dark_gray","text":"["},{"color":"dark_gray","text":"❁"},{"color":"dark_gray","text":"] "},{"color":"dark_gray","text":"["},{"color":"dark_gray","text":"⚔"},{"color":"dark_gray","text":"]"}],"italic":false,"text":""}',
+ '{"italic":false,"text":""}',
+ '{"extra":[{"color":"blue","text":"Depth Strider III"},{"color":"blue","text":", "},{"color":"blue","text":"Feather Falling X"},{"color":"blue","text":", "},{"color":"blue","text":"Growth V"}],"italic":false,"text":""}',
+ '{"extra":[{"color":"blue","text":"Protection V"}],"italic":false,"text":""}',
+ '{"italic":false,"text":""}',
+ '{"extra":[{"color":"gray","text":"Reduces the damage you take from"}],"italic":false,"text":""}',
+ '{"extra":[{"color":"gray","text":"withers by "},{"color":"red","text":"10%"},{"color":"gray","text":"."}],"italic":false,"text":""}',
+ '{"italic":false,"text":""}',
+ '{"extra":[{"color":"gold","text":"Full Set Bonus: Witherborn "},{"color":"gray","text":"(3/4)"}],"italic":false,"text":""}',
+ '{"extra":[{"color":"gray","text":"Spawns a wither minion every "},{"color":"yellow","text":"30"}],"italic":false,"text":""}',
+ '{"extra":[{"color":"yellow","text":""},{"color":"gray","text":"seconds up to a maximum "},{"color":"green","text":"1 "},{"color":"gray","text":"wither."}],"italic":false,"text":""}',
+ '{"extra":[{"color":"gray","text":"Your withers will travel to and"}],"italic":false,"text":""}',
+ '{"extra":[{"color":"gray","text":"explode on nearby enemies."}],"italic":false,"text":""}',
+ '{"italic":false,"text":""}',
+ '{"extra":[{"color":"blue","text":"Ancient Bonus"}],"italic":false,"text":""}',
+ '{"extra":[{"color":"gray","text":"Grants "},{"color":"green","text":"+1 "},{"color":"blue","text":"☠ Crit Damage "},{"color":"gray","text":"per"}],"italic":false,"text":""}',
+ '{"extra":[{"color":"gray","text":""},{"color":"red","text":"Catacombs "},{"color":"gray","text":"level."}],"italic":false,"text":""}',
+ '{"italic":false,"text":""}',
+ '{"extra":[{"bold":true,"color":"light_purple","obfuscated":true,"text":"a"},"",{"bold":false,"extra":[" "],"italic":false,"obfuscated":false,"strikethrough":false,"text":"","underlined":false},{"bold":true,"color":"light_purple","text":"MYTHIC DUNGEON BOOTS "},{"bold":true,"color":"light_purple","obfuscated":true,"text":"a"}],"italic":false,"text":""}'
+ ],
+ "minecraft:unbreakable": {
+ show_in_tooltip: 0b
+ }
+ },
+ count: 1,
+ id: "minecraft:leather_boots"
+}
diff --git a/translations/en_us.json b/translations/en_us.json
index 8321112..ac557f3 100644
--- a/translations/en_us.json
+++ b/translations/en_us.json
@@ -8,6 +8,8 @@
"firmament.command.waypoint.clear": "Cleared waypoints.",
"firmament.command.waypoint.import": "Imported %s waypoints from clipboard.",
"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.ordered.toggle.false": "Disabled ordered waypoints",
+ "firmament.command.waypoint.ordered.toggle.true": "Enabled ordered waypoints",
"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": "Skipped 1 waypoint",