From a185b78486334e849c92fb618ce69fc375b3f44f Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 23 Mar 2018 19:34:45 +0000 Subject: [PATCH] Player: fixed logic of move-into-bad-chunk checks particularly the hack with chunk switching was causing unexpected behaviour wrt. invisible players. --- src/pocketmine/Player.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 0b39ee2edb..e6438cef47 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -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; } }