Collect unallocated chunks from the Level provider

This commit is contained in:
Shoghi Cervantes 2014-12-07 18:26:59 +01:00
parent e4557a2e8e
commit 68da4b5b39
4 changed files with 9 additions and 3 deletions

View File

@ -2206,6 +2206,12 @@ class Level implements ChunkManager, Metadatable{
} }
} }
foreach($this->provider->getLoadedChunks() as $chunk){
if(!isset($this->chunks[Level::chunkHash($chunk->getX(), $chunk->getZ())])){
$this->provider->unloadChunk($chunk->getX(), $chunk->getZ(), false);
}
}
$this->timings->doChunkGC->stopTiming(); $this->timings->doChunkGC->stopTiming();
} }

View File

@ -214,7 +214,7 @@ interface LevelProvider{
public function setSpawn(Vector3 $pos); public function setSpawn(Vector3 $pos);
/** /**
* @return Chunk * @return Chunk[]
*/ */
public function getLoadedChunks(); public function getLoadedChunks();

View File

@ -77,7 +77,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
} }
if(count($heightMap) === 256){ if(count($heightMap) === 256){
$this->heightMap = 256; $this->heightMap = $heightMap;
}else{ }else{
$this->heightMap = array_fill(0, 256, 127); $this->heightMap = array_fill(0, 256, 127);
} }

View File

@ -105,7 +105,7 @@ abstract class BaseFullChunk implements FullChunk{
} }
if(count($heightMap) === 256){ if(count($heightMap) === 256){
$this->heightMap = 256; $this->heightMap = $heightMap;
}else{ }else{
$this->heightMap = array_fill(0, 256, 127); $this->heightMap = array_fill(0, 256, 127);
} }