Level: don't create objects which aren't going to be used

This commit is contained in:
Dylan K. Taylor 2018-03-16 13:00:16 +00:00
parent e3cae7364f
commit 9c786089f8

View File

@ -878,10 +878,10 @@ class Level implements ChunkManager, Metadatable{
if($optimizeRebuilds){ if($optimizeRebuilds){
$chunks = []; $chunks = [];
foreach($blocks as $b){ foreach($blocks as $b){
$pk = new UpdateBlockPacket();
if($b === null){ if($b === null){
continue; continue;
} }
$pk = new UpdateBlockPacket();
$first = false; $first = false;
if(!isset($chunks[$index = Level::chunkHash($b->x >> 4, $b->z >> 4)])){ if(!isset($chunks[$index = Level::chunkHash($b->x >> 4, $b->z >> 4)])){
@ -908,10 +908,10 @@ class Level implements ChunkManager, Metadatable{
} }
}else{ }else{
foreach($blocks as $b){ foreach($blocks as $b){
$pk = new UpdateBlockPacket();
if($b === null){ if($b === null){
continue; continue;
} }
$pk = new UpdateBlockPacket();
$pk->x = $b->x; $pk->x = $b->x;
$pk->y = $b->y; $pk->y = $b->y;