Improved flat world initial chunk generation speed by ~50%

This commit is contained in:
Dylan K. Taylor 2017-07-27 21:57:28 +01:00
parent 8274f5b3cc
commit c1542d853f

View File

@ -118,8 +118,18 @@ class Flat extends Generator{
for($Z = 0; $Z < 16; ++$Z){
for($X = 0; $X < 16; ++$X){
$this->chunk->setBiomeId($X, $Z, $biome);
for($y = 0; $y < 256 and isset($this->structure[$y]); ++$y){
$this->chunk->setBlock($X, $y, $Z, ...$this->structure[$y]);
}
}
for($sy = 0; $sy < 256; $sy += 16){
$subchunk = $this->chunk->getSubChunk($sy >> 4, true);
for($y = 0; $y < 16 and isset($this->structure[$y | $sy]); ++$y){
list($id, $meta) = $this->structure[$y | $sy];
for($Z = 0; $Z < 16; ++$Z){
for($X = 0; $X < 16; ++$X){
$subchunk->setBlock($X, $y, $Z, $id, $meta);
}
}
}
}