Coords suggestion for fill and exportschematic

This commit is contained in:
2026-11-17 08:07:01 -03:00
parent eedaa955f6
commit 188b05f598
3 changed files with 56 additions and 4 deletions
+26
View File
@@ -241,3 +241,29 @@ Deno.test("/fill replaces every block between two corners, both included", async
assertEquals(game.world.get_block_id(50, 120, 50), "cubi:air");
assertEquals(say("/fill 0 0 0 1 1 1 bworld:nothing"), "There's no block bworld:nothing");
});
Deno.test("/fill and /exportschematic suggest the block the player is looking at for each corner", async () => {
const { game, join, take, send } = await test_game("mods");
join(1, "alice");
for (let z = -6; z <= 1; z++) {
for (let y = 150; y <= 152; y++) game.set_block(0, y, z, "cubi:air");
}
// looking north, level, at a block 3 away at eye height
send(1, { type: "move", x: 0.5, y: 150, z: 0.5, yaw: 0, pitch: 0 });
const suggest = (text: string) => {
take(1);
send(1, { type: "suggest", id: 1, text });
return take(1).find((m) => m.type === "suggestions").suggestions.map((s: { text: string }) => s.text);
};
assertEquals(suggest("/fill "), []);
game.set_block(0, 151, -3, "bworld:stone");
assertEquals(suggest("/fill "), ["0 151 -3"]);
assertEquals(suggest("/fill 0 "), ["151 -3"]);
assertEquals(suggest("/fill 0 151 "), ["-3"]);
assertEquals(suggest("/fill 5"), []);
assertEquals(suggest("/fill 0 151 -3 "), ["0 151 -3"]);
assertEquals(suggest("/fill 0 151 -3 0 151 "), ["-3"]);
assertEquals(suggest("/exportschematic "), ["0 151 -3"]);
assertEquals(suggest("/exportschematic 0 151 -3 0 "), ["151 -3"]);
});