small rewrite of how movement packets are sent to players

This commit is contained in:
GameHerobrine 2023-10-30 07:14:18 +03:00
parent 5b8aee19fa
commit 6c08b74394
3 changed files with 96 additions and 14 deletions

View file

@ -362,6 +362,7 @@ class Level{
}
}
$this->totalMobsAmount = 0;
$post = [];
foreach($this->entityList as $k => $e){
if(!($e instanceof Entity)){
unset($this->entityList[$k]);
@ -373,8 +374,20 @@ class Level{
}
if($e->isPlayer() || $e->needsUpdate){
$e->update();
if(!$e->isPlayer()) $post[] = $k;
}
}
foreach($this->players as $player){
foreach($post as $eid){
$e = $this->entityList[$eid] ?? false;
if(!($e instanceof Entity)){
continue;
}
$player->addEntityMovementUpdateToQueue($e);
}
$player->sendEntityMovementUpdateQueue();
}
$this->checkSleep();