Dimension api

This commit is contained in:
2026-11-05 23:34:43 -03:00
parent 34f001285d
commit 4766c9a808
14 changed files with 251 additions and 27 deletions
+3 -3
View File
@@ -169,7 +169,8 @@ export class ServerWorld {
#spawn: { x: number; y: number; z: number } | undefined;
// where new players start: the dry land closest to the middle of the world, like minecraft's world spawn
// where new players start: the ground closest to the middle of the world, like minecraft's world spawn. ground is
// a column whose top block has collision, so not water or a plant
spawn_point() {
if (!this.#spawn) {
this.#spawn = this.#find_spawn();
@@ -178,7 +179,6 @@ export class ServerWorld {
}
#find_spawn() {
const water = this.block_ids["bworld:water"];
// chunks in rings around the middle, one column each
for (let radius = 0; radius <= SPAWN_SEARCH_CHUNKS; radius++) {
for (let cz = -radius; cz <= radius; cz++) {
@@ -188,7 +188,7 @@ export class ServerWorld {
const z = cz * CHUNK_SIZE + CHUNK_SIZE / 2;
let y = CHUNK_HEIGHT - 1;
while (y > 0 && this.get_block_nid(x, y, z) === AIR) y--;
if (y > 0 && this.get_block_nid(x, y, z) !== water) {
if (y > 0 && this.get_block_info(x, y, z)?.has_collision) {
return { x: x + 0.5, y: y + 1, z: z + 0.5 };
}
}