BlueGit

timfa questward

Simulate a 5x5 chunk ring around active players.

Client entity vision stays 3x3; spawners and mob AI now keep ticking one chunk further out.

timfa Tim Falken · pushed by timfa

Authored 2026-08-30 · 2 months ago

Hash
4b2fa39637899e3585892b651885f9e562d7e110
Parent
f5f6c00d
2 files changed +8 −3
server/tests/coordinates.test.js +3 −2
@@ -52,12 +52,13 @@ test("true floor division for negative coordinates", () =>
52 52 assert.equal(tileToRegion(-1), -1);
53 53 });
54 54
55 test("a player ChunkLoader stimulates 3x3 chunks and keeps 3x3 regions resident", () =>
55 test("a player ChunkLoader stimulates 5x5 chunks and keeps 3x3 regions resident", () =>
56 56 {
57 57 const coverage = loaderCoverage(8, 8, DEFAULT_CHUNK_LOADER);
58 assert.equal(coverage.simulationChunks.length, 9);
58 assert.equal(coverage.simulationChunks.length, 25);
59 59 assert.ok(coverage.simulationChunks.some((chunk) => chunk.chunkX === 0 && chunk.chunkY === 0));
60 60 assert.ok(coverage.simulationChunks.some((chunk) => chunk.chunkX === 1 && chunk.chunkY === 1));
61 assert.ok(coverage.simulationChunks.some((chunk) => chunk.chunkX === -2 && chunk.chunkY === 2));
61 62 assert.equal(coverage.residentRegions.length, 9);
62 63 assert.ok(coverage.residentRegions.some((region) => region.regionX === 0 && region.regionY === 0));
63 64 assert.ok(coverage.residentRegions.some((region) => region.regionX === 1 && region.regionY === 0));
@@ -52,12 +52,13 @@ test("true floor division for negative coordinates", () =>
52 assert.equal(tileToRegion(-1), -1);
52 assert.equal(tileToRegion(-1), -1);
53});
53});
54
54
55test("a player ChunkLoader stimulates 3x3 chunks and keeps 3x3 regions resident", () =>
55test("a player ChunkLoader stimulates 5x5 chunks and keeps 3x3 regions resident", () =>
56{
56{
57 const coverage = loaderCoverage(8, 8, DEFAULT_CHUNK_LOADER);
57 const coverage = loaderCoverage(8, 8, DEFAULT_CHUNK_LOADER);
58 assert.equal(coverage.simulationChunks.length, 9);
58 assert.equal(coverage.simulationChunks.length, 25);
59 assert.ok(coverage.simulationChunks.some((chunk) => chunk.chunkX === 0 && chunk.chunkY === 0));
59 assert.ok(coverage.simulationChunks.some((chunk) => chunk.chunkX === 0 && chunk.chunkY === 0));
60 assert.ok(coverage.simulationChunks.some((chunk) => chunk.chunkX === 1 && chunk.chunkY === 1));
60 assert.ok(coverage.simulationChunks.some((chunk) => chunk.chunkX === 1 && chunk.chunkY === 1));
61 assert.ok(coverage.simulationChunks.some((chunk) => chunk.chunkX === -2 && chunk.chunkY === 2));
61 assert.equal(coverage.residentRegions.length, 9);
62 assert.equal(coverage.residentRegions.length, 9);
62 assert.ok(coverage.residentRegions.some((region) => region.regionX === 0 && region.regionY === 0));
63 assert.ok(coverage.residentRegions.some((region) => region.regionX === 0 && region.regionY === 0));
63 assert.ok(coverage.residentRegions.some((region) => region.regionX === 1 && region.regionY === 0));
64 assert.ok(coverage.residentRegions.some((region) => region.regionX === 1 && region.regionY === 0));
shared/protocol/constants.js +5 −1
@@ -18,8 +18,12 @@ export const STATIC_CHUNK_RADIUS = 2;
18 18 /** If an entity has a path but has not left its tile for this long, repath. */
19 19 export const NAV_STUCK_MS = 5000;
20 20
21 /**
22 * Player ChunkLoader: simulation ring can be larger than client vision.
23 * simulationRadiusChunks 2 → 5×5 chunks tick; VISIBLE_CHUNK_RADIUS stays 1 (3×3 entity view).
24 */
21 25 export const DEFAULT_CHUNK_LOADER = Object.freeze({
22 simulationRadiusChunks: 1,
26 simulationRadiusChunks: 2,
23 27 regionLoadRadius: 1
24 28 });
25 29
@@ -18,8 +18,12 @@ export const STATIC_CHUNK_RADIUS = 2;
18/** If an entity has a path but has not left its tile for this long, repath. */
18/** If an entity has a path but has not left its tile for this long, repath. */
19export const NAV_STUCK_MS = 5000;
19export const NAV_STUCK_MS = 5000;
20
20
21/**
22 * Player ChunkLoader: simulation ring can be larger than client vision.
23 * simulationRadiusChunks 2 → 5×5 chunks tick; VISIBLE_CHUNK_RADIUS stays 1 (3×3 entity view).
24 */
21export const DEFAULT_CHUNK_LOADER = Object.freeze({
25export const DEFAULT_CHUNK_LOADER = Object.freeze({
22 simulationRadiusChunks: 1,
26 simulationRadiusChunks: 2,
23 regionLoadRadius: 1
27 regionLoadRadius: 1
24});
28});
25
29