3D biomes

This commit is contained in:
2026-11-07 12:13:43 -03:00
parent b726ce9695
commit 22191d260c
53 changed files with 874 additions and 316 deletions
+5 -6
View File
@@ -1607,8 +1607,8 @@ export class GameServer {
});
}
// like minecraft's /locate biome: columns LOCATE_STEP apart, in square rings out from x, z. the closest in the
// first ring that has one
// like minecraft's /locate biome: columns LOCATE_STEP apart, in square rings out from x, z, each from its ground
// down. the closest in the first ring that has one
#locate_biome(biome: string, x: number, z: number) {
for (let ring = 0; ring * LOCATE_STEP <= LOCATE_RADIUS; ring++) {
let best: { x: number; y: number; z: number; distance: number } | undefined;
@@ -1616,11 +1616,10 @@ export class GameServer {
for (let dz = -ring; dz <= ring; dz++) {
if (Math.max(Math.abs(dx), Math.abs(dz)) !== ring) continue;
const [cx, cz] = [x + dx * LOCATE_STEP, z + dz * LOCATE_STEP];
const found = this.world.estimate_biome(cx, cz);
const distance = Math.hypot(dx, dz);
if (found.biome === biome && (!best || distance < best.distance)) {
best = { x: cx, y: found.y, z: cz, distance };
}
if (best && distance >= best.distance) continue;
const y = this.world.locate_biome(biome, cx, cz);
if (y !== undefined) best = { x: cx, y, z: cz, distance };
}
}
if (best) return best;