diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index d5be76a9c..bc70c81c2 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -476,8 +476,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } public function setFlying(bool $value){ - $this->flying = $value; - $this->sendSettings(); + if($this->flying !== $value){ + $this->flying = $value; + $this->resetFallDistance(); + $this->sendSettings(); + } } public function isFlying() : bool{ @@ -1410,19 +1413,17 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->allowFlight = $this->isCreative(); if($this->isSpectator()){ - $this->flying = true; + $this->setFlying(true); $this->keepMovement = true; $this->despawnFromAll(); }else{ $this->keepMovement = $this->allowMovementCheats; if($this->isSurvival()){ - $this->flying = false; + $this->setFlying(false); } $this->spawnToAll(); } - $this->resetFallDistance(); - $this->namedtag->setInt("playerGameType", $this->gamemode); if(!$client){ //Gamemode changed by server, do not send for client changes $this->sendGamemode(); @@ -1679,6 +1680,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->newPosition = null; } + public function fall(float $fallDistance) : void{ + if(!$this->flying){ + parent::fall($fallDistance); + } + } + public function jump() : void{ (new PlayerJumpEvent($this))->call(); parent::jump(); @@ -2942,8 +2949,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $ev->call(); if($ev->isCancelled()){ $this->sendSettings(); - }else{ + }else{ //don't use setFlying() here, to avoid feedback loops $this->flying = $ev->isFlying(); + $this->resetFallDistance(); } $handled = true;