Implemented per world setting to keep the spawn in memory or not.

This commit is contained in:
Rigby
2011-07-27 00:24:27 +01:00
committed by EvilSeph
parent 6ae23e3f03
commit 4117d6b65e
5 changed files with 48 additions and 22 deletions

View File

@@ -783,4 +783,26 @@ public class CraftWorld implements World {
public int getMaxHeight() {
return 128;
}
public boolean getKeepSpawnInMemory() {
return world.keepSpawnInMemory;
}
public void setKeepSpawnInMemory(boolean keepLoaded) {
world.keepSpawnInMemory = keepLoaded;
// Grab the worlds spawn chunk
ChunkCoordinates chunkcoordinates = this.world.getSpawn();
int chunkCoordX = chunkcoordinates.x >> 4;
int chunkCoordZ = chunkcoordinates.z >> 4;
// Cycle through the 25x25 Chunks around it to load/unload the chunks.
for (int x = -12; x <= 12; x++) {
for (int z = -12; z <= 12; z++) {
if (keepLoaded) {
loadChunk(chunkCoordX + x, chunkCoordZ + z);
} else {
unloadChunk(chunkCoordX + x, chunkCoordZ + z);
}
}
}
}
}