mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 09:49:50 +00:00
Fixed entity visibility Player object memory leak, close #416
This commit is contained in:
parent
217f66e180
commit
2079e2fd88
@ -3100,6 +3100,9 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
foreach($this->usedChunks as $index => $d){
|
||||
Level::getXZ($index, $chunkX, $chunkZ);
|
||||
$this->level->unregisterChunkLoader($this, $chunkX, $chunkZ);
|
||||
foreach($this->level->getChunkEntities($chunkX, $chunkZ) as $entity){
|
||||
$entity->despawnFrom($this, false);
|
||||
}
|
||||
unset($this->usedChunks[$index]);
|
||||
}
|
||||
|
||||
|
@ -708,11 +708,13 @@ abstract class Entity extends Location implements Metadatable{
|
||||
/**
|
||||
* @param Player $player
|
||||
*/
|
||||
public function despawnFrom(Player $player){
|
||||
public function despawnFrom(Player $player, bool $send = true){
|
||||
if(isset($this->hasSpawned[$player->getLoaderId()])){
|
||||
$pk = new RemoveEntityPacket();
|
||||
$pk->eid = $this->id;
|
||||
$player->dataPacket($pk);
|
||||
if($send){
|
||||
$pk = new RemoveEntityPacket();
|
||||
$pk->eid = $this->id;
|
||||
$player->dataPacket($pk);
|
||||
}
|
||||
unset($this->hasSpawned[$player->getLoaderId()]);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user