Locate biome

This commit is contained in:
2026-10-02 14:16:50 -03:00
parent d2dde8c14f
commit 5a018a0470
4 changed files with 92 additions and 12 deletions
+16
View File
@@ -10,6 +10,7 @@ import {
literal,
word,
} from "$/common/commands.ts";
import { estimate_biome } from "$/common/worldgen/overworld.ts";
import { test_game } from "./helpers.ts";
interface Source {
@@ -157,3 +158,18 @@ Deno.test("/give suggests item ids as they're typed", async () => {
send(1, { type: "chat", text: "/give" });
assertEquals(take(1).find((m) => m.type === "chat").text, "Not enough: /give <item> [<count>]");
});
Deno.test("/locatebiome says where the nearest biome of a kind is", async () => {
const { game, join, take, send } = await test_game("mods");
join(1, "alice");
take(1);
const say = (text: string) => {
send(1, { type: "chat", text });
return take(1).filter((m) => m.type === "chat").map((m) => m.text).join("\n");
};
const answer = say("/locatebiome bworld:plains");
const [x, , z] = answer.match(/at (-?\d+) (-?\d+) (-?\d+)/)!.slice(1).map(Number);
assertEquals(estimate_biome(game.world.seed, x, z).biome, "bworld:plains");
assert(say("/locatebiome bworld:nowhere").includes("There's no biome bworld:nowhere"));
});