mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Player: add ability to get & set flight speed multiplier (#6076)
Since this doesn't directly correspond to flight speed (it's multiplied by different values depending on whether sprinting or not, and possibly other states), "multiplier" was preferred instead of directly calling it flight speed. Default value is 0.05.
This commit is contained in:
parent
847ae26cad
commit
f349ce75e4
@ -1058,8 +1058,7 @@ class NetworkSession{
|
|||||||
];
|
];
|
||||||
|
|
||||||
$layers = [
|
$layers = [
|
||||||
//TODO: dynamic flying speed! FINALLY!!!!!!!!!!!!!!!!!
|
new AbilitiesLayer(AbilitiesLayer::LAYER_BASE, $boolAbilities, $for->getFlightSpeedMultiplier(), 0.1),
|
||||||
new AbilitiesLayer(AbilitiesLayer::LAYER_BASE, $boolAbilities, 0.05, 0.1),
|
|
||||||
];
|
];
|
||||||
if(!$for->hasBlockCollision()){
|
if(!$for->hasBlockCollision()){
|
||||||
//TODO: HACK! In 1.19.80, the client starts falling in our faux spectator mode when it clips into a
|
//TODO: HACK! In 1.19.80, the client starts falling in our faux spectator mode when it clips into a
|
||||||
|
@ -184,6 +184,8 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
private const MAX_REACH_DISTANCE_SURVIVAL = 7;
|
private const MAX_REACH_DISTANCE_SURVIVAL = 7;
|
||||||
private const MAX_REACH_DISTANCE_ENTITY_INTERACTION = 8;
|
private const MAX_REACH_DISTANCE_ENTITY_INTERACTION = 8;
|
||||||
|
|
||||||
|
public const DEFAULT_FLIGHT_SPEED_MULTIPLIER = 0.05;
|
||||||
|
|
||||||
public const TAG_FIRST_PLAYED = "firstPlayed"; //TAG_Long
|
public const TAG_FIRST_PLAYED = "firstPlayed"; //TAG_Long
|
||||||
public const TAG_LAST_PLAYED = "lastPlayed"; //TAG_Long
|
public const TAG_LAST_PLAYED = "lastPlayed"; //TAG_Long
|
||||||
private const TAG_GAME_MODE = "playerGameType"; //TAG_Int
|
private const TAG_GAME_MODE = "playerGameType"; //TAG_Int
|
||||||
@ -285,6 +287,8 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
protected bool $blockCollision = true;
|
protected bool $blockCollision = true;
|
||||||
protected bool $flying = false;
|
protected bool $flying = false;
|
||||||
|
|
||||||
|
protected float $flightSpeedMultiplier = self::DEFAULT_FLIGHT_SPEED_MULTIPLIER;
|
||||||
|
|
||||||
/** @phpstan-var positive-int|null */
|
/** @phpstan-var positive-int|null */
|
||||||
protected ?int $lineHeight = null;
|
protected ?int $lineHeight = null;
|
||||||
protected string $locale = "en_US";
|
protected string $locale = "en_US";
|
||||||
@ -518,6 +522,41 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
return $this->flying;
|
return $this->flying;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the player's flight speed multiplier.
|
||||||
|
*
|
||||||
|
* Normal flying speed in blocks-per-tick is (multiplier * 10) blocks per tick.
|
||||||
|
* When sprint-flying, this is doubled to 20.
|
||||||
|
*
|
||||||
|
* If set to zero, the player will not be able to move in the xz plane when flying.
|
||||||
|
* Negative values will invert the controls.
|
||||||
|
*
|
||||||
|
* Note: Movement speed attribute does not influence flight speed.
|
||||||
|
*
|
||||||
|
* @see Player::DEFAULT_FLIGHT_SPEED_MULTIPLIER
|
||||||
|
*/
|
||||||
|
public function setFlightSpeedMultiplier(float $flightSpeedMultiplier) : void{
|
||||||
|
if($this->flightSpeedMultiplier !== $flightSpeedMultiplier){
|
||||||
|
$this->flightSpeedMultiplier = $flightSpeedMultiplier;
|
||||||
|
$this->getNetworkSession()->syncAbilities($this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the player's flight speed multiplier.
|
||||||
|
*
|
||||||
|
* Normal flying speed in blocks-per-tick is (multiplier * 10) blocks per tick.
|
||||||
|
* When sprint-flying, this is doubled to 20.
|
||||||
|
*
|
||||||
|
* If set to zero, the player will not be able to move in the xz plane when flying.
|
||||||
|
* Negative values will invert the controls.
|
||||||
|
*
|
||||||
|
* @see Player::DEFAULT_FLIGHT_SPEED_MULTIPLIER
|
||||||
|
*/
|
||||||
|
public function getFlightSpeedMultiplier() : float{
|
||||||
|
return $this->flightSpeedMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
public function setAutoJump(bool $value) : void{
|
public function setAutoJump(bool $value) : void{
|
||||||
if($this->autoJump !== $value){
|
if($this->autoJump !== $value){
|
||||||
$this->autoJump = $value;
|
$this->autoJump = $value;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user