Player: fixed setPosition() resending all the chunks

closes #3977
This commit is contained in:
Dylan K. Taylor 2020-12-21 00:09:49 +00:00
parent 2ba47a80a4
commit e762b79aae
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -651,16 +651,19 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
protected function setPosition(Vector3 $pos) : bool{
$oldWorld = $this->location->isValid() ? $this->location->getWorld() : null;
if(parent::setPosition($pos)){
if($oldWorld !== null){
foreach($this->usedChunks as $index => $status){
World::getXZ($index, $X, $Z);
$this->unloadChunk($X, $Z, $oldWorld);
$newWorld = $this->getWorld();
if($oldWorld !== $newWorld){
if($oldWorld !== null){
foreach($this->usedChunks as $index => $status){
World::getXZ($index, $X, $Z);
$this->unloadChunk($X, $Z, $oldWorld);
}
}
}
$this->usedChunks = [];
$this->loadQueue = [];
$this->networkSession->onEnterWorld();
$this->usedChunks = [];
$this->loadQueue = [];
$this->networkSession->onEnterWorld();
}
return true;
}