mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
Improved chunk cache, clean invalid chunks
This commit is contained in:
parent
19d391b9b2
commit
3ee61d5ebb
@ -1294,7 +1294,13 @@ class Level implements ChunkManager, Metadatable{
|
||||
* @return Chunk
|
||||
*/
|
||||
public function getChunkAt($x, $z, $create = false){
|
||||
return isset($this->chunks[$index = "$x:$z"]) ? $this->chunks[$index] : $this->chunks[$index] = $this->provider->getChunk($x, $z, $create);
|
||||
if(isset($this->chunks[$index = "$x:$z"])){
|
||||
return $this->chunks[$index];
|
||||
}elseif(($chunk = $this->provider->getChunk($x, $z, $create)) instanceof FullChunk){
|
||||
$this->chunks[$index] = $chunk;
|
||||
return $chunk;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function generateChunkCallback($x, $z, FullChunk $chunk){
|
||||
|
@ -121,7 +121,7 @@ class GenerationChunkManager implements ChunkManager{
|
||||
}
|
||||
|
||||
public function generateChunk($chunkX, $chunkZ){
|
||||
$this->chunks[Level::chunkHash($chunkX, $chunkZ)] = $this->requestChunk($chunkX, $chunkZ);
|
||||
$this->getChunk($chunkX, $chunkZ);
|
||||
$this->generator->generateChunk($chunkX, $chunkZ);
|
||||
$this->setChunkGenerated($chunkX, $chunkZ);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user