Client side chunk sections
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
// player, and which chunks are in a player's view. see "Chunk Streaming" in docs/modding_plan.md
|
||||
import { deflateSync, inflateSync } from "fflate";
|
||||
import { Reader, Writer } from "./bytes.ts";
|
||||
import { type ChunkColumn, read_column, to_flat, write_column } from "./section.ts";
|
||||
import { type ChunkColumn, read_column, type Section, write_column } from "./section.ts";
|
||||
|
||||
// the view distances clients can ask for, in chunks, like minecraft's
|
||||
export const MIN_VIEW_DISTANCE = 2;
|
||||
@@ -35,9 +35,9 @@ export function is_within_view(
|
||||
export interface LevelChunk {
|
||||
x: number;
|
||||
z: number;
|
||||
// block values (numeric id | state bits << 16) in the sender's numbering, y from the bottom of the world, then z,
|
||||
// then x. the dimension's whole height
|
||||
blocks: Uint32Array;
|
||||
// block values (numeric id | state bits << 16) in the receiver's numbering, see decode_level_chunk. from the bottom
|
||||
// of the world up, the dimension's whole height
|
||||
sections: Section[];
|
||||
// each column's biome, x then z
|
||||
biomes: string[];
|
||||
}
|
||||
@@ -70,5 +70,5 @@ export function decode_level_chunk(bytes: Uint8Array, map: (value: number) => nu
|
||||
const reader = new Reader(inflateSync(bytes.subarray(9)));
|
||||
const { sections, biomes } = read_column(reader, map);
|
||||
if (!reader.done) throw new Error("Wrong size");
|
||||
return { x, z, blocks: to_flat(sections), biomes };
|
||||
return { x, z, sections, biomes };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user