Level->sendBlocks() now syncs tiles

This commit is contained in:
Dylan K. Taylor 2019-02-23 16:52:30 +00:00
parent e1ef52c7c3
commit eadb1d310e
3 changed files with 7 additions and 20 deletions

View File

@ -2254,13 +2254,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
$this->level->sendBlocks([$this], $blocks);
foreach($blocks as $b){
$tile = $this->level->getTile($b);
if($tile instanceof Spawnable){
$tile->spawnTo($this);
}
}
return false;
}
@ -2490,7 +2483,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
throw new BadPacketException($e->getMessage(), 0, $e);
}
if(!$t->updateCompoundTag($compound, $this)){
$t->spawnTo($this);
$this->level->sendBlocks([$this], [$pos]);
}
}
@ -2508,7 +2501,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
$ev->call();
if($ev->isCancelled()){
$tile->spawnTo($this);
$this->level->sendBlocks([$this], [$tile]);
return true;
}

View File

@ -975,8 +975,12 @@ class Level implements ChunkManager, Metadatable{
$fullBlock = $this->getFullBlock($b->x, $b->y, $b->z);
$pk->blockRuntimeId = BlockFactory::toStaticRuntimeId($fullBlock >> 4, $fullBlock & 0xf);
}
$packets[] = $pk;
$tile = $this->getTileAt($b->x, $b->y, $b->z);
if($tile instanceof Spawnable){
$packets[] = $tile->createSpawnPacket();
}
}
$this->server->broadcastPackets($target, $packets);

View File

@ -50,16 +50,6 @@ abstract class Spawnable extends Tile{
return $pk;
}
public function spawnTo(Player $player) : bool{
if($this->closed){
return false;
}
$player->sendDataPacket($this->createSpawnPacket());
return true;
}
/**
* Flags the tile as modified, so that updates will be broadcasted at the next available opportunity.
* This MUST be called any time a change is made that players must be able to see.