mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-05 11:27:07 +00:00
Revert "Entity: remove redundant check from spawnTo()"
This reverts commit 3028832cd35c53937bb6502f74d3ad53646b12a7. When I created this commit, I made the flawed assumption that spawnTo() would not be used by plugins. In addition, I was not aware that there are some usages of spawnTo() in the core which do not check for chunk usage, such as in Player->showPlayer(). This caused a collection of problems including memory leaks and crashes due to disconnecting players not removing their references from viewed entities. The reverted commit may be the cause of #3178.
This commit is contained in:
parent
ce27c03774
commit
dbbe1f2d5c
@ -2048,7 +2048,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
* @param Player $player
|
||||
*/
|
||||
public function spawnTo(Player $player) : void{
|
||||
if(!isset($this->hasSpawned[$player->getLoaderId()])){
|
||||
if(!isset($this->hasSpawned[$player->getLoaderId()]) and $this->chunk !== null and isset($player->usedChunks[Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())])){
|
||||
$this->hasSpawned[$player->getLoaderId()] = $player;
|
||||
|
||||
$this->sendSpawnPacket($player);
|
||||
|
Loading…
x
Reference in New Issue
Block a user