Player: fixed logic of move-into-bad-chunk checks

particularly the hack with chunk switching was causing unexpected behaviour wrt. invisible players.
This commit is contained in:
Dylan K. Taylor 2018-03-23 19:34:45 +00:00
parent c19cf22ac5
commit a185b78486

View File

@ -1541,17 +1541,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->server->getLogger()->debug("Old position: " . $this->asVector3() . ", new position: " . $this->newPosition);
$revert = true;
}else{
if($this->chunk === null or !$this->chunk->isGenerated()){
$chunk = $this->level->getChunk($newPos->getFloorX() >> 4, $newPos->getFloorZ() >> 4, false);
if($chunk === null or !$chunk->isGenerated()){
$revert = true;
$this->nextChunkOrderRun = 0;
}else{
if($this->chunk !== null){
$this->chunk->removeEntity($this);
}
$this->chunk = $chunk;
}
$chunkX = $newPos->getFloorX() >> 4;
$chunkZ = $newPos->getFloorZ() >> 4;
if(!$this->level->isChunkLoaded($chunkX, $chunkZ) or !$this->level->isChunkGenerated($chunkX, $chunkZ)){
$revert = true;
$this->nextChunkOrderRun = 0;
}
}