World shape for dimension
This commit is contained in:
+10
-3
@@ -149,13 +149,20 @@ export async function test_game(
|
||||
|
||||
// the block id and state bits at x, y, z in the chunks among messages, read the way a client does with the table
|
||||
// join sent. undefined when no chunk there was sent
|
||||
// deno-lint-ignore no-explicit-any
|
||||
export function sent_block(messages: any[], join: { blocks: string[] }, x: number, y: number, z: number) {
|
||||
export function sent_block(
|
||||
// deno-lint-ignore no-explicit-any
|
||||
messages: any[],
|
||||
join: { blocks: string[]; shape: { min_y: number } },
|
||||
x: number,
|
||||
y: number,
|
||||
z: number,
|
||||
) {
|
||||
const chunk_x = Math.floor(x / CHUNK_SIZE);
|
||||
const chunk_z = Math.floor(z / CHUNK_SIZE);
|
||||
const chunk = messages.findLast((m) => m.type === "level_chunk" && m.x === chunk_x && m.z === chunk_z);
|
||||
if (!chunk) return undefined;
|
||||
const value = chunk.blocks[y * CHUNK_AREA + (z - chunk_z * CHUNK_SIZE) * CHUNK_SIZE + (x - chunk_x * CHUNK_SIZE)];
|
||||
const ly = y - join.shape.min_y;
|
||||
const value = chunk.blocks[ly * CHUNK_AREA + (z - chunk_z * CHUNK_SIZE) * CHUNK_SIZE + (x - chunk_x * CHUNK_SIZE)];
|
||||
return [join.blocks[value & ID_MASK], value >>> 16];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user