From 874fec0a35b91c94cd3759aca722db4fb3d832b9 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 9 Jul 2020 12:35:45 +0100 Subject: [PATCH] Switch back to PM3 spawn-chunk handling, fix pre-spawn death bug caused by 939dfd9269df0feaff5b96d0dd628055b9706b95, close #3513 (properly this time) --- src/player/Player.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/player/Player.php b/src/player/Player.php index db486f9d9..3852ce225 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -790,10 +790,10 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener, $this->networkSession->startUsingChunk($X, $Z, function(int $chunkX, int $chunkZ) use ($index) : void{ $this->usedChunks[$index] = UsedChunkStatus::SENT(); - if($this->spawned){ + if($this->spawnChunkLoadCount === -1){ $this->spawnEntitiesOnChunk($chunkX, $chunkZ); }elseif($this->spawnChunkLoadCount++ === $this->spawnThreshold){ - $this->spawned = true; + $this->spawnChunkLoadCount = -1; foreach($this->usedChunks as $chunkHash => $status){ if($status->equals(UsedChunkStatus::SENT())){ @@ -811,6 +811,10 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener, } public function doFirstSpawn() : void{ + if($this->spawned){ + return; + } + $this->spawned = true; if($this->hasPermission(Server::BROADCAST_CHANNEL_USERS)){ PermissionManager::getInstance()->subscribeToPermission(Server::BROADCAST_CHANNEL_USERS, $this); }