World sections
This commit is contained in:
@@ -7,6 +7,8 @@ import { assert, assertEquals } from "@std/assert";
|
||||
import { CHUNK_AREA, CHUNK_SIZE } from "@/common/constants.ts";
|
||||
import { decode_level_chunk, encode_level_chunk, is_within_view } from "@/common/chunk_streaming.ts";
|
||||
import { PROTOCOL_VERSION } from "@/common/protocol.ts";
|
||||
import { ChunkColumn } from "@/common/section.ts";
|
||||
import { WorldShape } from "@/common/world_shape.ts";
|
||||
import { sent_block, test_game } from "./helpers.ts";
|
||||
|
||||
Deno.test("a chunk comes back as it was encoded, whatever its sections hold", () => {
|
||||
@@ -21,8 +23,9 @@ Deno.test("a chunk comes back as it was encoded, whatever its sections hold", ()
|
||||
blocks[3 * section + i] = (i % 300) | ((i % 7) << 16);
|
||||
}
|
||||
const biomes = Array.from({ length: CHUNK_AREA }, (_, i) => i < 100 ? "bworld:plains" : "bworld:desert");
|
||||
const shape = new WorldShape({ min_y: -64, max_y: 320, sky_light: true });
|
||||
|
||||
const decoded = decode_level_chunk(encode_level_chunk({ x: -3, z: 70000, blocks, biomes }));
|
||||
const decoded = decode_level_chunk(encode_level_chunk(ChunkColumn.from_flat(-3, 70000, shape, blocks, biomes)));
|
||||
assertEquals(decoded.x, -3);
|
||||
assertEquals(decoded.z, 70000);
|
||||
assertEquals(decoded.blocks, blocks);
|
||||
@@ -30,7 +33,7 @@ Deno.test("a chunk comes back as it was encoded, whatever its sections hold", ()
|
||||
|
||||
// one biome, and the receiver's numbering
|
||||
const one = decode_level_chunk(
|
||||
encode_level_chunk({ x: 0, z: 0, blocks, biomes: biomes.map(() => "bworld:plains") }),
|
||||
encode_level_chunk(ChunkColumn.from_flat(0, 0, shape, blocks, biomes.map(() => "bworld:plains"))),
|
||||
(value) => value === 7 ? 70 : value,
|
||||
);
|
||||
assertEquals(one.biomes, biomes.map(() => "bworld:plains"));
|
||||
|
||||
Reference in New Issue
Block a user