Real ctx.world.is_loaded implementation

This commit is contained in:
2026-10-20 14:00:21 -03:00
parent 2c1eaf5735
commit 987e7a0f9a
5 changed files with 49 additions and 3 deletions
+7
View File
@@ -272,6 +272,13 @@ export class ServerWorld {
return this.#chunks.has(chunk_key(chunk_x, chunk_z));
}
// whether the chunk was ever generated: it's kept, or saved, so reading it generates nothing. it may not be in
// memory, then reading it decodes it from the save
is_generated(chunk_x: number, chunk_z: number) {
const key = chunk_key(chunk_x, chunk_z);
return this.#chunks.has(key) || this.#is_saved(key);
}
// counts as using the chunk so it's kept longer, if it's there. returns whether it is, see has_chunk
keep_chunk(chunk_x: number, chunk_z: number) {
return this.#chunks.get(chunk_key(chunk_x, chunk_z)) !== undefined;