Level: fixed logic for sending changed blocks to players

If there is an empty list of blocks in the changedBlocks array for a chunk, that means that blocks changed the normal way and then were later set the direct way in the same tick. This means that no action needs to be taken on these chunks.
This commit is contained in:
Dylan K. Taylor 2018-06-29 11:10:31 +01:00
parent d8824e7ee1
commit 57cfe9fd43

View File

@ -769,6 +769,9 @@ class Level implements ChunkManager, Metadatable{
if(count($this->changedBlocks) > 0){
if(count($this->players) > 0){
foreach($this->changedBlocks as $index => $blocks){
if(empty($blocks)){ //blocks can be set normally and then later re-set with direct send
continue;
}
unset($this->chunkCache[$index]);
Level::getXZ($index, $chunkX, $chunkZ);
if(count($blocks) > 512){
@ -776,7 +779,7 @@ class Level implements ChunkManager, Metadatable{
foreach($this->getChunkPlayers($chunkX, $chunkZ) as $p){
$p->onChunkChanged($chunk);
}
}elseif(!empty($blocks)){
}else{
$this->sendBlocks($this->getChunkPlayers($chunkX, $chunkZ), $blocks, UpdateBlockPacket::FLAG_ALL);
}
}