Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flight speed #6076

Open
wants to merge 17 commits into
base: minor-next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/network/mcpe/NetworkSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -930,8 +930,7 @@ public function syncAbilities(Player $for) : void{
];

$layers = [
//TODO: dynamic flying speed! FINALLY!!!!!!!!!!!!!!!!!
new AbilitiesLayer(AbilitiesLayer::LAYER_BASE, $boolAbilities, 0.05, 0.1),
new AbilitiesLayer(AbilitiesLayer::LAYER_BASE, $boolAbilities, $for->getFlySpeed(), 0.1),
];
if(!$for->hasBlockCollision()){
//TODO: HACK! In 1.19.80, the client starts falling in our faux spectator mode when it clips into a
Expand Down
13 changes: 13 additions & 0 deletions src/player/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
private const MAX_REACH_DISTANCE_SURVIVAL = 7;
private const MAX_REACH_DISTANCE_ENTITY_INTERACTION = 8;

public const DEFAULT_FLY_SPEED = 0.05;

public const TAG_FIRST_PLAYED = "firstPlayed"; //TAG_Long
public const TAG_LAST_PLAYED = "lastPlayed"; //TAG_Long
private const TAG_GAME_MODE = "playerGameType"; //TAG_Int
Expand Down Expand Up @@ -278,6 +280,8 @@ public static function isValidUserName(?string $name) : bool{
protected bool $blockCollision = true;
protected bool $flying = false;

protected float $flySpeed = self::DEFAULT_FLY_SPEED;

/** @phpstan-var positive-int|null */
protected ?int $lineHeight = null;
protected string $locale = "en_US";
Expand Down Expand Up @@ -515,6 +519,15 @@ public function hasAutoJump() : bool{
return $this->autoJump;
}

public function setFlySpeed(float $flySpeed) : void{
Sergittos marked this conversation as resolved.
Show resolved Hide resolved
$this->flySpeed = $flySpeed;
$this->getNetworkSession()->syncAbilities($this);
}

public function getFlySpeed() : float{
return $this->flySpeed;
}

public function spawnTo(Player $player) : void{
if($this->isAlive() && $player->isAlive() && $player->canSee($this) && !$this->isSpectator()){
parent::spawnTo($player);
Expand Down