diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 6e43936f3..4e48ff07e 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -284,14 +284,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** @var Vector3|null */ protected $newPosition; - /** @var Vector3|null */ - public $speed = null; /** @var bool */ protected $isTeleporting = false; /** @var int */ protected $inAirTicks = 0; - /** @var int */ - protected $startAirTicks = 5; /** @var float */ protected $stepHeight = 0.6; /** @var bool */ @@ -546,9 +542,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ public function resetFallDistance() : void{ parent::resetFallDistance(); - if($this->inAirTicks !== 0){ - $this->startAirTicks = 5; - } $this->inAirTicks = 0; } @@ -1614,10 +1607,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } } } - - $this->speed = $to->subtract($from)->divide($tickDiff); - }elseif($distanceSquared == 0){ - $this->speed = new Vector3(0, 0, 0); } if($revert){ @@ -1649,10 +1638,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ if(parent::setMotion($motion)){ $this->broadcastMotion(); - if($this->motion->y > 0){ - $this->startAirTicks = (-log($this->gravity / ($this->gravity + $this->drag * $this->motion->y)) / $this->drag) * 2 + 5; - } - return true; } return false; @@ -1706,6 +1691,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ if($this->spawned){ $this->processMovement($tickDiff); $this->motion->x = $this->motion->y = $this->motion->z = 0; //TODO: HACK! (Fixes player knockback being messed up) + if($this->onGround){ + $this->inAirTicks = 0; + }else{ + $this->inAirTicks += $tickDiff; + } Timings::$timerEntityBaseTick->startTiming(); $this->entityBaseTick($tickDiff); @@ -1715,32 +1705,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ Timings::$playerCheckNearEntitiesTimer->startTiming(); $this->checkNearEntities(); Timings::$playerCheckNearEntitiesTimer->stopTiming(); - - if($this->speed !== null){ - if($this->onGround){ - if($this->inAirTicks !== 0){ - $this->startAirTicks = 5; - } - $this->inAirTicks = 0; - }else{ - if(!$this->allowFlight and $this->inAirTicks > 10 and !$this->isSleeping() and !$this->isImmobile()){ - $expectedVelocity = (-$this->gravity) / $this->drag - ((-$this->gravity) / $this->drag) * exp(-$this->drag * ($this->inAirTicks - $this->startAirTicks)); - $diff = ($this->speed->y - $expectedVelocity) ** 2; - - if(!$this->hasEffect(Effect::JUMP) and !$this->hasEffect(Effect::LEVITATION) and $diff > 0.6 and $expectedVelocity < $this->speed->y and !$this->server->getAllowFlight()){ - if($this->inAirTicks < 100){ - $this->setMotion(new Vector3(0, $expectedVelocity, 0)); - }elseif($this->kick($this->server->getLanguage()->translateString("kick.reason.cheat", ["%ability.flight"]))){ - $this->timings->stopTiming(); - - return false; - } - } - } - - $this->inAirTicks += $tickDiff; - } - } } } @@ -2891,7 +2855,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $handled = false; $isFlying = $packet->getFlag(AdventureSettingsPacket::FLYING); - if($isFlying and !$this->allowFlight and !$this->server->getAllowFlight()){ + if($isFlying and !$this->allowFlight){ $this->kick($this->server->getLanguage()->translateString("kick.reason.cheat", ["%ability.flight"])); return true; }elseif($isFlying !== $this->isFlying()){ diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 2646a0a2e..e7fff4cfd 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -556,10 +556,11 @@ class Server{ } /** + * @deprecated * @return bool */ public function getAllowFlight() : bool{ - return $this->getConfigBool("allow-flight", false); + return true; } /** @@ -1470,7 +1471,6 @@ class Server{ "announce-player-achievements" => true, "spawn-protection" => 16, "max-players" => 20, - "allow-flight" => false, "spawn-animals" => true, "spawn-mobs" => true, "gamemode" => 0,