Skip to content

Commit 16cc3b2

Browse files
committed
feat: Add relative waypoints to import coords relative to a structure
1 parent 03cf4e4 commit 16cc3b2

File tree

3 files changed

+113
-15
lines changed

3 files changed

+113
-15
lines changed

src/main/kotlin/features/world/Waypoints.kt

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -208,30 +208,58 @@ object Waypoints : FirmamentFeature {
208208
it.z)
209209
})
210210
ClipboardUtils.setTextContent(data)
211-
source.sendFeedback(tr("firmament.command.waypoint.export", "Copied ${waypoints.size} waypoints to clipboard"))
211+
source.sendFeedback(tr("firmament.command.waypoint.export",
212+
"Copied ${waypoints.size} waypoints to clipboard"))
213+
}
214+
}
215+
thenLiteral("exportrelative") {
216+
thenExecute {
217+
val playerPos = MC.player!!.blockPos
218+
val x = playerPos.x
219+
val y = playerPos.y
220+
val z = playerPos.z
221+
val data = Firmament.tightJson.encodeToString<List<ColeWeightWaypoint>>(waypoints.map {
222+
ColeWeightWaypoint(it.x - x,
223+
it.y - y,
224+
it.z - z)
225+
})
226+
ClipboardUtils.setTextContent(data)
227+
source.sendFeedback(tr("firmament.command.waypoint.export.relative",
228+
"Copied ${waypoints.size} relative waypoints to clipboard. Make sure to stand in the same position when importing."))
229+
212230
}
213231
}
214232
thenLiteral("import") {
215233
thenExecute {
216-
val contents = ClipboardUtils.getTextContents()
217-
val data = try {
218-
Firmament.tightJson.decodeFromString<List<ColeWeightWaypoint>>(contents)
219-
} catch (ex: Exception) {
220-
Firmament.logger.error("Could not load waypoints from clipboard", ex)
221-
source.sendError(Text.translatable("firmament.command.waypoint.import.error"))
222-
return@thenExecute
223-
}
224-
waypoints.clear()
225-
data.mapTo(waypoints) { BlockPos(it.x, it.y, it.z) }
226234
source.sendFeedback(
227-
Text.stringifiedTranslatable(
228-
"firmament.command.waypoint.import",
229-
data.size
230-
)
235+
importRelative(BlockPos.ORIGIN)
236+
?: Text.stringifiedTranslatable("firmament.command.waypoint.import", waypoints.size),
231237
)
232238
}
233239
}
240+
thenLiteral("importrelative") {
241+
thenExecute {
242+
source.sendFeedback(
243+
importRelative(MC.player!!.blockPos)
244+
?: tr("firmament.command.waypoint.import.relative",
245+
"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."),
246+
)
247+
}
248+
}
249+
}
250+
}
251+
252+
fun importRelative(pos: BlockPos): Text? {
253+
val contents = ClipboardUtils.getTextContents()
254+
val data = try {
255+
Firmament.tightJson.decodeFromString<List<ColeWeightWaypoint>>(contents)
256+
} catch (ex: Exception) {
257+
Firmament.logger.error("Could not load waypoints from clipboard", ex)
258+
return (Text.translatable("firmament.command.waypoint.import.error"))
234259
}
260+
waypoints.clear()
261+
data.mapTo(waypoints) { BlockPos(it.x + pos.x, it.y + pos.y, it.z + pos.z) }
262+
return null
235263
}
236264

237265
@Subscribe
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
components: {
3+
"minecraft:attribute_modifiers": {
4+
modifiers: [
5+
],
6+
show_in_tooltip: 0b
7+
},
8+
"minecraft:custom_data": {
9+
enchantments: {
10+
depth_strider: 3,
11+
feather_falling: 10,
12+
growth: 5,
13+
protection: 5
14+
},
15+
id: "POWER_WITHER_BOOTS",
16+
modifier: "ancient",
17+
rarity_upgrades: 1,
18+
timestamp: 1704550620000L,
19+
upgrade_level: 5,
20+
uuid: "8b6c7485-cb59-44d3-ac8f-9e52a611cc64"
21+
},
22+
"minecraft:custom_name": '{"extra":[{"color":"light_purple","text":"Ancient Necron\'s Boots "},{"color":"gold","text":"✪✪✪✪✪"}],"italic":false,"text":""}',
23+
"minecraft:dyed_color": {
24+
rgb: 15167036,
25+
show_in_tooltip: 0b
26+
},
27+
"minecraft:enchantments": {
28+
levels: {
29+
"minecraft:depth_strider": 3
30+
}
31+
},
32+
"minecraft:hide_additional_tooltip": {
33+
},
34+
"minecraft:lore": [
35+
'{"extra":[{"color":"gray","text":"Gear Score: "},{"color":"light_purple","text":"713 "},{"color":"dark_gray","text":"(2753)"}],"italic":false,"text":""}',
36+
'{"extra":[{"color":"gray","text":"Strength: "},{"color":"red","text":"+79 "},{"color":"blue","text":"(+35) "},{"color":"dark_gray","text":"(+333.75)"}],"italic":false,"text":""}',
37+
'{"extra":[{"color":"gray","text":"Crit Chance: "},{"color":"red","text":"+15% "},{"color":"blue","text":"(+15%) "},{"color":"dark_gray","text":"(+23.1%)"}],"italic":false,"text":""}',
38+
'{"extra":[{"color":"gray","text":"Crit Damage: "},{"color":"red","text":"+71% "},{"color":"blue","text":"(+38%) "},{"color":"dark_gray","text":"(+302.6%)"}],"italic":false,"text":""}',
39+
'{"extra":[{"color":"gray","text":"Health: "},{"color":"green","text":"+241.5 "},{"color":"blue","text":"(+7) "},{"color":"dark_gray","text":"(+1,010.15)"}],"italic":false,"text":""}',
40+
'{"extra":[{"color":"gray","text":"Defense: "},{"color":"green","text":"+120.5 "},{"color":"blue","text":"(+7) "},{"color":"dark_gray","text":"(+498.4)"}],"italic":false,"text":""}',
41+
'{"extra":[{"color":"gray","text":"Intelligence: "},{"color":"green","text":"+36 "},{"color":"blue","text":"(+25) "},{"color":"dark_gray","text":"(+155.75)"}],"italic":false,"text":""}',
42+
'{"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":""}',
43+
'{"italic":false,"text":""}',
44+
'{"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":""}',
45+
'{"extra":[{"color":"blue","text":"Protection V"}],"italic":false,"text":""}',
46+
'{"italic":false,"text":""}',
47+
'{"extra":[{"color":"gray","text":"Reduces the damage you take from"}],"italic":false,"text":""}',
48+
'{"extra":[{"color":"gray","text":"withers by "},{"color":"red","text":"10%"},{"color":"gray","text":"."}],"italic":false,"text":""}',
49+
'{"italic":false,"text":""}',
50+
'{"extra":[{"color":"gold","text":"Full Set Bonus: Witherborn "},{"color":"gray","text":"(3/4)"}],"italic":false,"text":""}',
51+
'{"extra":[{"color":"gray","text":"Spawns a wither minion every "},{"color":"yellow","text":"30"}],"italic":false,"text":""}',
52+
'{"extra":[{"color":"yellow","text":""},{"color":"gray","text":"seconds up to a maximum "},{"color":"green","text":"1 "},{"color":"gray","text":"wither."}],"italic":false,"text":""}',
53+
'{"extra":[{"color":"gray","text":"Your withers will travel to and"}],"italic":false,"text":""}',
54+
'{"extra":[{"color":"gray","text":"explode on nearby enemies."}],"italic":false,"text":""}',
55+
'{"italic":false,"text":""}',
56+
'{"extra":[{"color":"blue","text":"Ancient Bonus"}],"italic":false,"text":""}',
57+
'{"extra":[{"color":"gray","text":"Grants "},{"color":"green","text":"+1 "},{"color":"blue","text":"☠ Crit Damage "},{"color":"gray","text":"per"}],"italic":false,"text":""}',
58+
'{"extra":[{"color":"gray","text":""},{"color":"red","text":"Catacombs "},{"color":"gray","text":"level."}],"italic":false,"text":""}',
59+
'{"italic":false,"text":""}',
60+
'{"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":""}'
61+
],
62+
"minecraft:unbreakable": {
63+
show_in_tooltip: 0b
64+
}
65+
},
66+
count: 1,
67+
id: "minecraft:leather_boots"
68+
}

translations/en_us.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"firmament.command.waypoint.clear": "Cleared waypoints.",
99
"firmament.command.waypoint.import": "Imported %s waypoints from clipboard.",
1010
"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}]",
11+
"firmament.command.waypoint.ordered.toggle.false": "Disabled ordered waypoints",
12+
"firmament.command.waypoint.ordered.toggle.true": "Enabled ordered waypoints",
1113
"firmament.command.waypoint.remove": "Removed waypoint %s. Other waypoints may have different indexes now.",
1214
"firmament.command.waypoint.remove.error": "Could not find waypoint with that index to delete.",
1315
"firmament.command.waypoint.skip": "Skipped 1 waypoint",

0 commit comments

Comments
 (0)