Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
29 changes: 29 additions & 0 deletions include/endstone/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,35 @@ class Player : public Mob, public OfflinePlayer {
*/
virtual void setFlySpeed(float value) const = 0;

/**
* @brief Gets the current allowed speed that a client can fly up and down.
*
* @return The current allowed speed, default is 1.
*/
[[nodiscard]] virtual float getVerticalFlySpeed() const = 0;


/**
* Sets the speed at which a client will fly up and down.
*
* @param value The new speed.
*/
virtual void setVerticalFlySpeed(float value) const = 0;

/**
* @brief Determines if the Player has noclip ability enabled
*
* @return True if player has noclip enabled
*/
[[nodiscard]] virtual bool getNoClip() const = 0;

/**
* @brief Sets if the Player has noclip or not.
*
* @param noclip If noclip should be enabled.
*/
virtual void setNoClip(bool noclip) const = 0;

/**
* @brief Gets the current allowed speed that a client can walk.
*
Expand Down
22 changes: 22 additions & 0 deletions src/endstone/core/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,28 @@ void EndstonePlayer::setFlySpeed(float value) const
updateAbilities();
}

float EndstonePlayer::getVerticalFlySpeed() const
{
return getHandle().getAbilities().getFloat(AbilitiesIndex::VerticalFlySpeed);
}

void EndstonePlayer::setVerticalFlySpeed(float value) const
{
getHandle().getAbilities().setAbility(AbilitiesIndex::VerticalFlySpeed, value);
updateAbilities();
}

bool EndstonePlayer::getNoClip() const
{
return getHandle().getAbilities().getBool(AbilitiesIndex::NoClip);
}

void EndstonePlayer::setNoClip(bool noclip) const
{
getHandle().getAbilities().setAbility(AbilitiesIndex::NoClip, noclip);
updateAbilities();
}

float EndstonePlayer::getWalkSpeed() const
{
return getHandle().getAbilities().getFloat(AbilitiesIndex::WalkSpeed);
Expand Down
4 changes: 4 additions & 0 deletions src/endstone/core/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ class EndstonePlayer : public EndstoneMobBase<Player, ::Player> {
Result<void> setFlying(bool value) override;
[[nodiscard]] float getFlySpeed() const override;
void setFlySpeed(float value) const override;
[[nodiscard]] float getVerticalFlySpeed() const override;
void setVerticalFlySpeed(float value) const override;
[[nodiscard]] bool getNoClip() const override;
void setNoClip(bool noclip) const override;
[[nodiscard]] float getWalkSpeed() const override;
void setWalkSpeed(float value) const override;
[[nodiscard]] Scoreboard &getScoreboard() const override;
Expand Down
4 changes: 4 additions & 0 deletions src/endstone/python/endstone_python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ void init_player(py::module_ &m, py::class_<OfflinePlayer> &offline_player,
"If the Player is allowed to fly via jump key double-tap.")
.def_property("fly_speed", &Player::getFlySpeed, &Player::setFlySpeed,
"Gets or sets the current allowed speed that a client can fly.")
.def_property("vertical_fly_speed", &Player::getVerticalFlySpeed, &Player::setVerticalFlySpeed,
"Gets or sets the current allowed speed that a client can fly up and down.")
.def_property("noclip", &Player::getNoClip, &Player::getNoClip,
"Gets or sets if client has noclip ability enabled.")
.def_property("walk_speed", &Player::getWalkSpeed, &Player::setWalkSpeed,
"Gets or sets the current allowed speed that a client can walk.")
.def_property("scoreboard", &Player::getScoreboard, &Player::setScoreboard,
Expand Down