World shape for dimension
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
// monsters spawning on their own in the dark near players, like undergarden's rotwalkers, see natural_spawner.ts and
|
||||
// mods/undergarden/worldgen/spawns.json
|
||||
import { assert, assertEquals } from "@std/assert";
|
||||
import { CHUNK_HEIGHT, CHUNK_SIZE } from "@/common/constants.ts";
|
||||
import { CHUNK_SIZE } from "@/common/constants.ts";
|
||||
import { decode_level_chunk } from "@/common/chunk_streaming.ts";
|
||||
import {
|
||||
block_light_emission,
|
||||
@@ -31,8 +31,8 @@ async function setup(roof = "bworld:stone") {
|
||||
const x0 = CHUNK * CHUNK_SIZE;
|
||||
for (let x = x0; x < x0 + CHUNK_SIZE; x++) {
|
||||
for (let z = x0; z < x0 + CHUNK_SIZE; z++) {
|
||||
for (let y = 0; y < FLOOR; y++) world.set_block(x, y, z, "bworld:stone");
|
||||
for (let y = ROOF + 1; y < CHUNK_HEIGHT; y++) world.set_block(x, y, z, "cubi:air");
|
||||
for (let y = world.shape.min_y; y < FLOOR; y++) world.set_block(x, y, z, "bworld:stone");
|
||||
for (let y = ROOF + 1; y < world.shape.max_y; y++) world.set_block(x, y, z, "cubi:air");
|
||||
}
|
||||
}
|
||||
for (let x = x0 - 1; x <= x0 + CHUNK_SIZE; x++) {
|
||||
@@ -86,7 +86,7 @@ Deno.test("the server's light is the same as what clients work out", async () =>
|
||||
emission[nid] = block_light_emission(block);
|
||||
});
|
||||
opacity[REGION_VOID] = 15;
|
||||
const region = new LightRegion();
|
||||
const region = new LightRegion(world.shape);
|
||||
const chunks = [];
|
||||
for (let dz = -1; dz <= 1; dz++) {
|
||||
for (let dx = -1; dx <= 1; dx++) {
|
||||
@@ -97,7 +97,8 @@ Deno.test("the server's light is the same as what clients work out", async () =>
|
||||
region.compute({ opacity, emission });
|
||||
|
||||
const check = (x: number, y: number, z: number) => {
|
||||
const index = y * REGION_LAYER + (z - x0 + CHUNK_SIZE) * REGION_SIZE + x - x0 + CHUNK_SIZE;
|
||||
const index = (y - world.shape.min_y) * REGION_LAYER + (z - x0 + CHUNK_SIZE) * REGION_SIZE + x - x0 +
|
||||
CHUNK_SIZE;
|
||||
const expected = { sky: region.sky[index], block: region.block_light[index] };
|
||||
assertEquals(world.light_at(x, y, z), expected, `at ${x}, ${y}, ${z}`);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user