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