Base class for all player types (Local, Server, Remote).
More...
#include <SDK.h>
|
| float | getHealth () const |
| | Get the player's current health.
|
| void | setHealth (float health) |
| | Set the player's health directly.
|
| float | getMaxHealth () const |
| | Get the player's maximum health.
|
| bool | hurt (DamageSource *source, float amount) |
| | Apply damage from a damage source.
|
| void | heal (float amount) |
| | Heal the player by a given amount.
|
| int | getFoodLevel () const |
| | Get the player's current food level.
|
| int | getExperienceLevel () const |
| | Get the player's experience level.
|
| void | giveExperienceLevels (int amount) |
| | Give experience levels to the player.
|
| wstring | getName () const |
| | Get the player's username.
|
| bool | isSneaking () const |
| | Check if the player is currently sneaking.
|
| bool | isSprinting () const |
| | Check if the player is currently sprinting.
|
| bool | isFlying () const |
| | Check if the player is flying.
|
| void | setFlying (bool flying) |
| | Set the player's flying state.
|
|
double | getX () const |
| | Get the player's current X position.
|
|
double | getY () const |
| | Get the player's current Y position (feet level).
|
|
double | getZ () const |
| | Get the player's current Z position.
|
| void | teleportTo (double x, double y, double z) |
| | Teleport the player to a world position.
|
| virtual shared_ptr< ItemInstance > | getCarriedItem () |
| | Get the item currently held in the player's hand.
|
| class Inventory * | getInventory () |
| | Add an item to the player's inventory.
|
|
virtual void | respawn () |
| | Trigger the player's respawn.
|
|
void | kill () |
| | Kill the player immediately. Triggers death screen.
|
| virtual void | playSound (int soundId, float volume, float pitch) |
| | Play a sound effect at the player's position.
|
| bool | hasPermission (class EGameCommand command) |
| | Check whether this player has a given game permission.
|
|
|
double | x |
| | X coordinate (double precision).
|
|
double | y |
| | Y coordinate (feet position).
|
|
double | z |
| | Z coordinate.
|
|
float | yRot |
| | Yaw rotation in degrees.
|
|
float | xRot |
| | Pitch rotation in degrees.
|
Base class for all player types (Local, Server, Remote).
Don't use this directly — use MultiplayerLocalPlayer (client) or ServerPlayer (server) for concrete player references.
Definition at line 475 of file SDK.h.
◆ getCarriedItem()
| virtual shared_ptr< ItemInstance > Player::getCarriedItem |
( |
| ) |
|
|
virtual |
Get the item currently held in the player's hand.
- Returns
- ItemInstance pointer, or nullptr if hand is empty.
Reimplemented in LocalPlayer.
◆ getExperienceLevel()
| int Player::getExperienceLevel |
( |
| ) |
const |
Get the player's experience level.
- Returns
- XP level.
◆ getFoodLevel()
| int Player::getFoodLevel |
( |
| ) |
const |
Get the player's current food level.
- Returns
- Food level (0–20).
◆ getHealth()
| float Player::getHealth |
( |
| ) |
const |
Get the player's current health.
- Returns
- Health points (0.0 = dead, 20.0 = full with no buffs).
◆ getInventory()
| class Inventory * Player::getInventory |
( |
| ) |
|
Add an item to the player's inventory.
- Example
auto sword = std::make_shared<ItemInstance>(276, 1, 0);
player->getInventory()->add(sword);
◆ getMaxHealth()
| float Player::getMaxHealth |
( |
| ) |
const |
Get the player's maximum health.
- Returns
- Max health (default 20.0, affected by Absorption etc.).
◆ getName()
| wstring Player::getName |
( |
| ) |
const |
Get the player's username.
- Returns
- Wide string username.
◆ giveExperienceLevels()
| void Player::giveExperienceLevels |
( |
int | amount | ) |
|
Give experience levels to the player.
- Parameters
-
| amount | Number of levels to add (can be negative). |
◆ hasPermission()
| bool Player::hasPermission |
( |
class EGameCommand | command | ) |
|
Check whether this player has a given game permission.
- Parameters
-
| command | The permission/command to check. |
- Returns
- true if allowed.
◆ heal()
| void Player::heal |
( |
float | amount | ) |
|
Heal the player by a given amount.
- Parameters
-
| amount | Half-hearts to restore. |
◆ hurt()
| bool Player::hurt |
( |
DamageSource * | source, |
|
|
float | amount ) |
Apply damage from a damage source.
Respects armor, effects, and god-mode. Prefer this over setHealth() when simulating real damage, as it triggers death/hurt animations.
- Parameters
-
| source | Damage source (can be nullptr for generic damage). |
| amount | Damage in half-hearts. |
- Returns
- true if the damage was applied.
◆ isFlying()
| bool Player::isFlying |
( |
| ) |
const |
Check if the player is flying.
- Returns
- true if flying.
◆ isSneaking()
| bool Player::isSneaking |
( |
| ) |
const |
Check if the player is currently sneaking.
- Returns
- true if sneaking.
◆ isSprinting()
| bool Player::isSprinting |
( |
| ) |
const |
Check if the player is currently sprinting.
- Returns
- true if sprinting.
◆ playSound()
| virtual void Player::playSound |
( |
int | soundId, |
|
|
float | volume, |
|
|
float | pitch ) |
|
virtual |
Play a sound effect at the player's position.
- Parameters
-
| soundId | Sound ID. |
| volume | Volume multiplier (1.0 = normal). |
| pitch | Pitch multiplier (1.0 = normal). |
Reimplemented in LocalPlayer.
◆ setFlying()
| void Player::setFlying |
( |
bool | flying | ) |
|
Set the player's flying state.
- Parameters
-
| flying | True to enable flight. |
◆ setHealth()
| void Player::setHealth |
( |
float | health | ) |
|
Set the player's health directly.
Does not trigger death events if set to 0 — use hurt() for that. Clamped to [0, getMaxHealth()] internally.
- Parameters
-
- Example
player->setHealth(20.0f);
player->setHealth(1.0f);
◆ teleportTo()
| void Player::teleportTo |
( |
double | x, |
|
|
double | y, |
|
|
double | z ) |
Teleport the player to a world position.
- Parameters
-
The documentation for this class was generated from the following file: