diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index a470e2180..b7a7f9def 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -956,6 +956,11 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener, $world = $world ?? $this->world; $index = World::chunkHash($x, $z); if(isset($this->usedChunks[$index])){ + foreach($this->getWorld()->getChunkEntities($x, $z) as $entity){ + if($entity !== $this){ + $entity->despawnFrom($this); + } + } $this->networkSession->stopUsingChunk($x, $z); unset($this->usedChunks[$index]); } diff --git a/src/pocketmine/network/mcpe/NetworkSession.php b/src/pocketmine/network/mcpe/NetworkSession.php index f28d3b44a..508f3b266 100644 --- a/src/pocketmine/network/mcpe/NetworkSession.php +++ b/src/pocketmine/network/mcpe/NetworkSession.php @@ -790,11 +790,7 @@ class NetworkSession{ } public function stopUsingChunk(int $chunkX, int $chunkZ) : void{ - foreach($this->player->getWorld()->getChunkEntities($chunkX, $chunkZ) as $entity){ - if($entity !== $this->player){ - $entity->despawnFrom($this->player); - } - } + } public function tick() : bool{