Move attribute net sync to NetworkSession

This commit is contained in:
Dylan K. Taylor 2020-11-08 14:15:11 +00:00
parent 64afb6f2e2
commit f43d20b47a
2 changed files with 8 additions and 7 deletions

View File

@ -958,6 +958,14 @@ class NetworkSession{
if($this->player !== null){
$this->player->doChunkRequests();
$dirtyAttributes = $this->player->getAttributeMap()->needSend();
$this->syncAttributes($this->player, $dirtyAttributes);
foreach($dirtyAttributes as $attribute){
//TODO: we might need to send these to other players in the future
//if that happens, this will need to become more complex than a flag on the attribute itself
$attribute->markSynchronized();
}
}
$this->flushSendBuffer();

View File

@ -1322,13 +1322,6 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
$this->lastUpdate = $currentTick;
//TODO: move this to network session ticking (this is specifically related to net sync)
$dirtyAttributes = $this->attributeMap->needSend();
$this->networkSession->syncAttributes($this, $dirtyAttributes);
foreach($dirtyAttributes as $attribute){
$attribute->markSynchronized();
}
if(!$this->isAlive() and $this->spawned){
$this->onDeathUpdate($tickDiff);
return true;