Use newly added API method

This commit is contained in:
Dylan K. Taylor 2018-10-20 16:26:10 +01:00
parent 43426a4c5c
commit 4aef9919dc

View File

@ -1804,7 +1804,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->chunk = $this->level->getChunk($chunkX, $chunkZ, true);
if(!$this->justCreated){
$newChunk = $this->level->getChunkPlayers($chunkX, $chunkZ);
$newChunk = $this->level->getViewersForPosition($this);
foreach($this->hasSpawned as $player){
if(!isset($newChunk[$player->getLoaderId()])){
$this->despawnFrom($player);
@ -1963,7 +1963,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
if($this->chunk === null or $this->closed){
return;
}
foreach($this->level->getChunkPlayers($this->chunk->getX(), $this->chunk->getZ()) as $player){
foreach($this->level->getViewersForPosition($this) as $player){
if($player->isOnline()){
$this->spawnTo($player);
}