World shape for dimension

This commit is contained in:
2026-11-06 22:49:43 -03:00
parent 7458a2d42a
commit 818ce22dd6
60 changed files with 749 additions and 349 deletions
+4 -3
View File
@@ -4,7 +4,7 @@
// features are code or data, and use each other: data features with types and modifiers scripts register, scripts
// placing data features. they run by step, then mod, data before code. see docs/modding/worldgen/index.md
import { assert, assertEquals, assertRejects } from "@std/assert";
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "@/common/constants.ts";
import { CHUNK_AREA, CHUNK_SIZE } from "@/common/constants.ts";
import { generate_raw_chunk } from "@/common/generation.ts";
import { copy_dir, test_game } from "./helpers.ts";
@@ -98,15 +98,16 @@ Deno.test("data features use types and modifiers scripts register, scripts place
"testmod:place_one",
]);
const { min_y, max_y } = game.world.shape;
const at = (blocks: Uint32Array, x: number, y: number, z: number) =>
blocks[y * CHUNK_AREA + z * CHUNK_SIZE + x];
blocks[(y - min_y) * CHUNK_AREA + z * CHUNK_SIZE + x];
const glass = block_ids["bworld:glass"];
const cobble = block_ids["bworld:cobblestone"];
for (const [cx, cz] of [[0, 0], [3, -2]]) {
const { blocks } = generate_raw_chunk(cx, cz, game.world.seed, block_ids, worldgen, default_values);
// the pillar in the middle, which the code feature after it in its step saw
let pillar = 0;
for (let y = 0; y < CHUNK_HEIGHT; y++) if (at(blocks, 8, y, 8) === glass) pillar++;
for (let y = min_y; y < max_y; y++) if (at(blocks, 8, y, 8) === glass) pillar++;
assertEquals(pillar, 3);
assertEquals((globalThis as unknown as { glass_seen: number }).glass_seen, 3);
// the one place_one put at 2, 200, 2