mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-10 20:08:01 +00:00
Fixed fall handling when flying, closes #2709
This commit is contained in:
parent
71d17c50d6
commit
a150f39b02
@ -476,8 +476,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function setFlying(bool $value){
|
public function setFlying(bool $value){
|
||||||
$this->flying = $value;
|
if($this->flying !== $value){
|
||||||
$this->sendSettings();
|
$this->flying = $value;
|
||||||
|
$this->resetFallDistance();
|
||||||
|
$this->sendSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isFlying() : bool{
|
public function isFlying() : bool{
|
||||||
@ -1410,19 +1413,17 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
|
|
||||||
$this->allowFlight = $this->isCreative();
|
$this->allowFlight = $this->isCreative();
|
||||||
if($this->isSpectator()){
|
if($this->isSpectator()){
|
||||||
$this->flying = true;
|
$this->setFlying(true);
|
||||||
$this->keepMovement = true;
|
$this->keepMovement = true;
|
||||||
$this->despawnFromAll();
|
$this->despawnFromAll();
|
||||||
}else{
|
}else{
|
||||||
$this->keepMovement = $this->allowMovementCheats;
|
$this->keepMovement = $this->allowMovementCheats;
|
||||||
if($this->isSurvival()){
|
if($this->isSurvival()){
|
||||||
$this->flying = false;
|
$this->setFlying(false);
|
||||||
}
|
}
|
||||||
$this->spawnToAll();
|
$this->spawnToAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->resetFallDistance();
|
|
||||||
|
|
||||||
$this->namedtag->setInt("playerGameType", $this->gamemode);
|
$this->namedtag->setInt("playerGameType", $this->gamemode);
|
||||||
if(!$client){ //Gamemode changed by server, do not send for client changes
|
if(!$client){ //Gamemode changed by server, do not send for client changes
|
||||||
$this->sendGamemode();
|
$this->sendGamemode();
|
||||||
@ -1679,6 +1680,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
$this->newPosition = null;
|
$this->newPosition = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function fall(float $fallDistance) : void{
|
||||||
|
if(!$this->flying){
|
||||||
|
parent::fall($fallDistance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function jump() : void{
|
public function jump() : void{
|
||||||
(new PlayerJumpEvent($this))->call();
|
(new PlayerJumpEvent($this))->call();
|
||||||
parent::jump();
|
parent::jump();
|
||||||
@ -2942,8 +2949,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
$ev->call();
|
$ev->call();
|
||||||
if($ev->isCancelled()){
|
if($ev->isCancelled()){
|
||||||
$this->sendSettings();
|
$this->sendSettings();
|
||||||
}else{
|
}else{ //don't use setFlying() here, to avoid feedback loops
|
||||||
$this->flying = $ev->isFlying();
|
$this->flying = $ev->isFlying();
|
||||||
|
$this->resetFallDistance();
|
||||||
}
|
}
|
||||||
|
|
||||||
$handled = true;
|
$handled = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user