Cache fix related to #1813: Don't cache blocks for chunks that don't exist

This commit is contained in:
Dylan K. Taylor 2017-12-13 10:47:12 +00:00
parent 67a576722c
commit 131a6a4d19

View File

@ -1456,8 +1456,13 @@ class Level implements ChunkManager, Metadatable{
$index = Level::blockHash($x, $y, $z);
if($cached and isset($this->blockCache[$index])){
return $this->blockCache[$index];
}elseif(isset($this->chunks[$chunkIndex = Level::chunkHash($x >> 4, $z >> 4)])){
$fullState = $this->chunks[$chunkIndex]->getFullBlock($x & 0x0f, $y, $z & 0x0f);
}
$chunk = $this->chunks[$chunkIndex = Level::chunkHash($x >> 4, $z >> 4)] ?? null;
if($chunk !== null){
$fullState = $chunk->getFullBlock($x & 0x0f, $y, $z & 0x0f);
}else{
$addToCache = false;
}
}