World gen stuff
This commit is contained in:
+38
-1
@@ -25,6 +25,7 @@ function mods(options: {
|
||||
flat_default?: boolean;
|
||||
shape?: Pick<DimensionJson, "min_y" | "max_y" | "sky_light">;
|
||||
ground?: string;
|
||||
surface_rule?: unknown;
|
||||
cell_height?: number;
|
||||
}) {
|
||||
const dir = Deno.makeTempDirSync({ prefix: "bworld_dimensions_" });
|
||||
@@ -73,7 +74,8 @@ function mods(options: {
|
||||
steep: 100,
|
||||
biome_source: "flat:flat",
|
||||
fluids: [{ block: "bworld:water", below: SEA_TOP + 1, where: "open_sky" }],
|
||||
surface_rule: { type: "block", result_state: { Name: options.ground ?? "bworld:glass" } },
|
||||
surface_rule: options.surface_rule ??
|
||||
{ type: "block", result_state: { Name: options.ground ?? "bworld:glass" } },
|
||||
},
|
||||
});
|
||||
write("worldgen/dimension/flat.json", {
|
||||
@@ -96,6 +98,41 @@ Deno.test("the world is generated by the default dimension's noise settings, fro
|
||||
}
|
||||
});
|
||||
|
||||
Deno.test("a surface rule's density condition holds where its density function is in range", async () => {
|
||||
const block = (id: string) => ({ type: "block", result_state: { Name: id } });
|
||||
const dir = mods({
|
||||
flat: true,
|
||||
bworld_default: false,
|
||||
// glass where x is from 30 to 50, and below y 60 too
|
||||
surface_rule: {
|
||||
type: "sequence",
|
||||
sequence: [
|
||||
{
|
||||
type: "condition",
|
||||
if_true: { type: "density", function: { type: "x" }, min_inclusive: 30, max_exclusive: 50 },
|
||||
then_run: block("bworld:glass"),
|
||||
},
|
||||
{
|
||||
type: "condition",
|
||||
if_true: { type: "density", function: { type: "y" }, max_exclusive: 60 },
|
||||
then_run: block("bworld:glass"),
|
||||
},
|
||||
block("bworld:stone"),
|
||||
],
|
||||
},
|
||||
});
|
||||
const { game } = await test_game(dir);
|
||||
Deno.removeSync(dir, { recursive: true });
|
||||
const at = (x: number, y: number) => game.world.get_block_id(x, y, 5);
|
||||
assertEquals([29, 30, 49, 50].map((x) => at(x, GROUND_TOP)), [
|
||||
"bworld:stone",
|
||||
"bworld:glass",
|
||||
"bworld:glass",
|
||||
"bworld:stone",
|
||||
]);
|
||||
assertEquals([at(60, 60), at(60, 59)], ["bworld:stone", "bworld:glass"]);
|
||||
});
|
||||
|
||||
Deno.test("players spawn on ground with collision, not on the water in the middle of the world", async () => {
|
||||
const dir = mods({ flat: true, bworld_default: false });
|
||||
const { game, join } = await test_game(dir);
|
||||
|
||||
Reference in New Issue
Block a user