Move trees out of cubi
This commit is contained in:
+1
-8
@@ -19,7 +19,6 @@ const PLAIN = { id: "my_mod:flat", surface: { top: "bworld:grass_block", filler:
|
||||
Deno.test("the bworld mod registers every biome the overworld picks", async () => {
|
||||
await test_game("mods");
|
||||
assertEquals(biome_ids().length, 26);
|
||||
assertEquals(get_biome("bworld:dark_forest")?.trees?.wood.big_oak, "dark_oak");
|
||||
assertEquals(get_biome("bworld:river")?.surface.underwater_top, "bworld:sand");
|
||||
});
|
||||
|
||||
@@ -49,22 +48,16 @@ Deno.test("a biome follows the calendar unless it says otherwise", async () => {
|
||||
});
|
||||
|
||||
Deno.test("a biome's surface defaults: underwater is its filler, cliffs aren't bare", () => {
|
||||
const { surface, colors, trees } = biome_from_json(PLAIN);
|
||||
const { surface, colors } = biome_from_json(PLAIN);
|
||||
assertEquals(surface.underwater_top, "bworld:dirt");
|
||||
assertEquals(surface.underwater_filler, "bworld:dirt");
|
||||
assertEquals(surface.bare_cliffs, false);
|
||||
assertEquals(colors, { grass: undefined, foliage: undefined, water: undefined });
|
||||
assertEquals(trees, undefined);
|
||||
});
|
||||
|
||||
Deno.test("bad biome json is reported", () => {
|
||||
assertEquals(validate_biome(PLAIN), []);
|
||||
assert(validate_biome({ ...PLAIN, season: "monsoon" }).some((p) => p.startsWith("season")));
|
||||
assert(validate_biome({ ...PLAIN, colors: { grass: "green" } }).some((p) => p.startsWith("colors.grass")));
|
||||
// which kinds of tree there are is up to the trees feature, see tests/wood_test.ts
|
||||
assertEquals(validate_biome({ ...PLAIN, trees: { chance: 2, kinds: ["palm"] } }), [
|
||||
"trees.chance must be at most 1",
|
||||
]);
|
||||
assert(validate_biome({ ...PLAIN, trees: { chance: 1, kinds: [] } }).some((p) => p.startsWith("trees.kinds")));
|
||||
assert(validate_biome({ id: "my_mod:flat" }).some((p) => p.startsWith("surface")));
|
||||
});
|
||||
|
||||
+5
-21
@@ -1,15 +1,15 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { assert, assertEquals, assertRejects } from "@std/assert";
|
||||
import { assert, assertEquals } from "@std/assert";
|
||||
import { CHUNK_AREA, CHUNK_SIZE } from "@/common/constants.ts";
|
||||
import { Container, ItemStack } from "@/common/inventory.ts";
|
||||
import { CRAFTING_RESULT_SLOT } from "@/common/protocol.ts";
|
||||
import { generate_raw_chunk } from "@/common/generation.ts";
|
||||
import { get_biome } from "@/common/worldgen/biomes.ts";
|
||||
import { update_crafting_result } from "@/server/game/crafting.ts";
|
||||
import { recipe_lookup } from "@/common/mod_loader.ts";
|
||||
import { copy_dir, test_game } from "./helpers.ts";
|
||||
import { BIOME_TREES, wood_of as tree_wood } from "@/mods/bworld/scripts/trees.ts";
|
||||
import { test_game } from "./helpers.ts";
|
||||
|
||||
Deno.test("recipes that take planks take any kind, even mixed, but nothing else", async () => {
|
||||
const { game } = await test_game("mods");
|
||||
@@ -70,10 +70,8 @@ Deno.test("trees grow the wood of their kind and biome", async () => {
|
||||
// the trunk's ground's biome
|
||||
const y = game.world.shape.min_y + Math.floor(i / CHUNK_AREA) - 1;
|
||||
const biome = column.biome_at(cx * 16 + i % 16, y, cz * 16 + Math.floor(i / 16) % 16);
|
||||
const info = get_biome(biome)!;
|
||||
const allowed = info.trees!.kinds.map((kind) =>
|
||||
info.trees!.wood[kind] ?? (kind === "big_oak" ? "oak" : kind)
|
||||
);
|
||||
const trees = BIOME_TREES[biome];
|
||||
const allowed = trees ? trees.kinds.map((kind) => tree_wood(trees, kind)) : [];
|
||||
assert(
|
||||
allowed.includes(wood as never),
|
||||
`${wood} in ${biome} at ${cx * CHUNK_SIZE}, ${cz * CHUNK_SIZE}`,
|
||||
@@ -86,17 +84,3 @@ Deno.test("trees grow the wood of their kind and biome", async () => {
|
||||
// each tree's leaves are its own wood's
|
||||
assertEquals([...found_leaves].sort(), [...found].sort());
|
||||
});
|
||||
|
||||
Deno.test("a biome with a kind of tree bworld's trees don't have stops the server", async () => {
|
||||
const dir = Deno.makeTempDirSync({ prefix: "bworld_trees_" });
|
||||
copy_dir("mods/bworld", `${dir}/bworld`);
|
||||
const path = `${dir}/bworld/worldgen/biomes/forest.json`;
|
||||
const json = JSON.parse(Deno.readTextFileSync(path));
|
||||
json.biome.trees.kinds.push("palm");
|
||||
Deno.writeTextFileSync(path, JSON.stringify(json));
|
||||
try {
|
||||
await assertRejects(() => test_game(dir), Error, "biome bworld:forest: trees.kinds: palm isn't one of oak");
|
||||
} finally {
|
||||
Deno.removeSync(dir, { recursive: true });
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user