Cuberite
A lightweight, fast and extensible game server for Minecraft
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
cPlayer Class Reference

#include <Player.h>

Inheritance diagram for cPlayer:
Inheritance graph
[legend]
Collaboration diagram for cPlayer:
Collaboration graph
[legend]

Classes

struct  BodyStanceCrouching
 Tag representing a sneaking pose. More...
 
struct  BodyStanceGliding
 Tag representing a swimming or elytra flying pose. More...
 
struct  BodyStanceSleeping
 Tag representing a sleeping pose. More...
 
struct  BodyStanceSprinting
 Tag representing a sprinting pose. More...
 
struct  BodyStanceStanding
 Tag representing the neutral stance. More...
 

Public Member Functions

void AbortEating (void)
 Aborts the current eating operation. More...
 
void AddFoodExhaustion (double a_Exhaustion)
 Adds the specified exhaustion to m_FoodExhaustion. More...
 
void AddInventoryPaintSlot (int a_SlotNum)
 Adds a slot to the list for inventory painting. More...
 
void AddKnownItem (const cItem &a_Item)
 Adds an Item to the list of known items. More...
 
void AwardAchievement (CustomStatistic a_Ach)
 Awards the player an achievement. More...
 
void CancelChargingBow (void)
 Cancels the current bow charging. More...
 
virtual bool CanFly (void) const
 Returns wheter the player can fly or not. More...
 
bool CanInstantlyMine (BLOCKTYPE a_Block)
 Given tool, enchantments, status effects, and world position returns whether a_Block would be instantly mined. More...
 
bool CanMobsTarget (void) const
 Returns true if the player can be targeted by Mobs. More...
 
void ClearInventoryPaintSlots (void)
 Clears the list of slots that are being inventory-painted. More...
 
void CloseWindow (bool a_CanRefuse=true)
 Closes the current window, resets current window to m_InventoryWindow. More...
 
void CloseWindowIfID (char a_WindowID, bool a_CanRefuse=true)
 Closes the current window if it matches the specified ID, resets current window to m_InventoryWindow. More...
 
 cPlayer (const std::shared_ptr< cClientHandle > &a_Client)
 
int DeltaExperience (int a_Xp_delta)
 
bool DoesPlacingBlocksIntersectEntity (std::initializer_list< sSetBlock > a_Blocks) const
 Whether placing the given blocks would intersect any entitiy. More...
 
bool Feed (int a_Food, double a_Saturation)
 Adds to FoodLevel and FoodSaturationLevel, returns true if any food has been consumed, false if player "full". More...
 
int FinishChargingBow (void)
 Finishes charging the current bow. More...
 
void FinishEating (void)
 Finishes eating the currently equipped item. More...
 
void ForceSetSpeed (const Vector3d &a_Speed)
 Forces the player to move in the given direction. More...
 
void Freeze (const Vector3d &a_Location)
 Prevent the player from moving and lock him into a_Location. More...
 
cClientHandleGetClientHandle (void) const
 
AString GetColor (void) const
 Returns the full color code to use for this player, based on their rank. More...
 
int GetCurrentXp (void)
 Gets the current experience. More...
 
const AStringGetCustomName (void) const
 Returns the custom name of this player. More...
 
cItemGetDraggingItem (void)
 In UI windows, get the item that the player is dragging. More...
 
eGameMode GetEffectiveGameMode (void) const
 Returns the current effective gamemode (inherited gamemode is resolved before returning) More...
 
MTRand GetEnchantmentRandomProvider ()
 Get a copy of the PRNG for enchanting related generation, don't use this for other purposes. More...
 
cItemGridGetEnderChestContents (void)
 Gets the contents of the player's associated enderchest. More...
 
virtual cItem GetEquippedBoots (void) const override
 Returns the currently equipped boots; empty item if none. More...
 
virtual cItem GetEquippedChestplate (void) const override
 Returns the currently equipped chestplate; empty item if none. More...
 
virtual cItem GetEquippedHelmet (void) const override
 Returns the currently equipped helmet; empty item if none. More...
 
const cItemGetEquippedItem (void) const
 
virtual cItem GetEquippedLeggings (void) const override
 Returns the currently equipped leggings; empty item if none. More...
 
virtual cItem GetEquippedWeapon (void) const override
 Returns the curently equipped weapon; empty item if none. More...
 
double GetEyeHeight (void) const
 
Vector3d GetEyePosition (void) const
 
UInt32 GetFloaterID (void) const
 
double GetFlyingMaxSpeed (void) const
 Gets the flying relative maximum speed. More...
 
double GetFoodExhaustionLevel (void) const
 
int GetFoodLevel (void) const
 
double GetFoodSaturationLevel (void) const
 
int GetFoodTickTimer (void) const
 
eGameMode GetGameMode (void) const
 Returns the current gamemode. More...
 
cInventoryGetInventory (void)
 
const cInventoryGetInventory (void) const
 
const cSlotNumsGetInventoryPaintSlots (void) const
 Returns the list of slots currently stored for inventory painting. More...
 
AString GetIP (void) const
 
const std::set< UInt32 > & GetKnownRecipes () const
 Gets the set of IDs for recipes this player has discovered. More...
 
Vector3i GetLastBedPos (void) const
 Gets the player's potential respawn position (named LastBedPos for compatibility reasons). More...
 
const AStringGetLoadedWorldName () const
 
double GetMaxSpeed (void) const
 Returns the current relative maximum speed (takes current sprinting / flying state into account) More...
 
float GetMiningProgressPerTick (BLOCKTYPE a_Block)
 Returns the progress mined per tick for the block a_Block as a fraction (1 would be completely mined) Depends on hardness values so check those are correct. More...
 
const AStringGetName (void) const
 
double GetNormalMaxSpeed (void) const
 Gets the normal relative maximum speed. More...
 
virtual cItem GetOffHandEquipedItem (void) const override
 Returns the currently offhand equipped item; empty item if none. More...
 
const AStringVectorGetPermissions (void) const
 Returns all the permissions that the player has assigned to them. More...
 
AString GetPlayerListName (void) const
 Returns the name that is used in the playerlist. More...
 
AString GetPrefix (void) const
 Returns the player name prefix, may contain @ format directives. More...
 
cWorldGetRespawnWorld ()
 
const AStringVectorGetRestrictions (void) const
 Returns all the restrictions that the player has assigned to them. More...
 
int GetSkinParts (void) const
 
double GetSprintingMaxSpeed (void) const
 Gets the sprinting relative maximum speed. More...
 
StatisticsManagerGetStatistics ()
 Return the associated statistic and achievement manager. More...
 
AString GetSuffix (void) const
 Returns the player name suffix, may contain @ format directives. More...
 
cTeamGetTeam (void)
 Returns the associated team, nullptr if none. More...
 
const cTeamGetTeam (void) const
 Returns the associated team, nullptr if none. More...
 
Vector3d GetThrowSpeed (double a_SpeedCoeff) const
 Returns the initial speed vector of a throw, with a 3D length of a_SpeedCoeff. More...
 
Vector3d GetThrowStartPos (void) const
 Returns the position where projectiles thrown by this player should start, player eye position + adjustment. More...
 
const cUUIDGetUUID (void) const
 Returns the UUID that has been read from the client, or nil if not available. More...
 
cWindowGetWindow (void)
 
const cWindowGetWindow (void) const
 
int GetXpLevel (void) const
 Gets the current level - XpLevel. More...
 
int GetXpLifetimeTotal (void)
 Gets the experience total - XpTotal for score on death. More...
 
float GetXpPercentage (void) const
 Gets the experience bar percentage - XpP. More...
 
bool HasCustomName (void) const
 Returns true if the player has a custom name. More...
 
bool HasPermission (const AString &a_Permission) const
 
bool HasSkinPart (eSkinPart a_Part) const
 
virtual void Heal (int a_Health) override
 Heals the player by the specified amount of HPs (positive only); sends health update. More...
 
bool IsChargingBow (void) const
 Returns true if the player is currently charging the bow. More...
 
bool IsClimbing (void) const
 Returns whether the player is climbing (ladders, vines etc.) More...
 
virtual bool IsCrouched (void) const override
 
bool IsEating (void) const
 Returns true if the player is currently in the process of eating the currently equipped item. More...
 
virtual bool IsFireproof () const override
 Returns true if the player is fireproof Stops players burning in creative or spectator modes. More...
 
bool IsFishing (void) const
 Returns true if the player has thrown out a floater. More...
 
bool IsFlying (void) const
 Returns true if the player is currently flying. More...
 
bool IsFrozen ()
 Is the player frozen? More...
 
bool IsGameModeAdventure (void) const
 Returns true if the player is in Adventure mode, either explicitly, or by inheriting from current world. More...
 
bool IsGameModeCreative (void) const
 Returns true if the player is in Creative mode, either explicitly, or by inheriting from current world. More...
 
bool IsGameModeSpectator (void) const
 Returns true if the player is in Spectator mode, either explicitly, or by inheriting from current world. More...
 
bool IsGameModeSurvival (void) const
 Returns true if the player is in Survival mode, either explicitly, or by inheriting from current world. More...
 
bool IsInBed (void) const
 Returns true if a player is sleeping in a bed. More...
 
bool IsLeftHanded () const
 Returns true if the player's left hand is dominant. More...
 
virtual bool IsOnGround (void) const override
 Returns whether the entity is on ground or not. More...
 
bool IsRespawnPointForced (void) const
 Returns if the respawn point is unconditionally used. More...
 
bool IsSatiated (void) const
 Returns true if the player is satiated, i. More...
 
virtual bool IsSprinting (void) const override
 
bool IsStanding () const
 Returns true if a player is standing normally, that is, in a neutral pose. More...
 
virtual void Killed (const cEntity &a_Victim, eDamageType a_DamageType) override
 Called when the entity kills another entity. More...
 
virtual void KilledBy (TakeDamageInfo &a_TDI) override
 Called when the health drops below zero. More...
 
void LoadFromDisk ()
 Loads the player data from the save file. More...
 
void LoadRank (void)
 (Re)loads the rank and permissions from the cRankManager and sends a permission level update to the client. More...
 
void NotifyNearbyWolves (cPawn *a_Opponent, bool a_IsPlayerInvolved)
 Notify nearby wolves that the player or one of the player's wolves took damage or did damage to an entity. More...
 
void OnLoseSpectated ()
 Called when spectation stops, because the player crouched or when the entity we're spectating gets removed from the world. More...
 
void OpenHorseInventory ()
 Opens the inventory of any tame horse the player is riding. More...
 
void OpenWindow (cWindow &a_Window)
 Opens the specified window; closes the current one first using CloseWindow() More...
 
void PermuteEnchantmentSeed ()
 Permute the seed for enchanting related PRNGs, don't use this for other purposes. More...
 
bool PlaceBlock (Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
 Attempts to place the block in the world with a call to PlaceBlocks. More...
 
bool PlaceBlocks (std::initializer_list< sSetBlock > a_Blocks)
 Calls the block placement hooks and places the blocks in the world. More...
 
void ReplaceOneEquippedItemTossRest (const cItem &)
 Removes one item from the the current equipped item stack, and attempts to add the specified item stack back to the same slot. More...
 
void Respawn (void)
 
void SaveToDisk (void)
 Saves all player data, such as inventory, to JSON. More...
 
void SendAboveActionBarMessage (const AString &a_Message)
 
void SendAboveActionBarMessage (const cCompositeChat &a_Message)
 
void SendBlocksAround (Vector3i a_BlockPos, int a_Range=1)
 Sends the block in the specified range around the specified coord to the client as a block change packet. More...
 
void SendMessage (const AString &a_Message)
 
void SendMessage (const cCompositeChat &a_Message)
 
void SendMessageFailure (const AString &a_Message)
 
void SendMessageFatal (const AString &a_Message)
 
void SendMessageInfo (const AString &a_Message)
 
void SendMessagePrivateMsg (const AString &a_Message, const AString &a_Sender)
 
void SendMessageRaw (const AString &a_MessageRaw, eChatType a_Type=eChatType::ctChatBox)
 
void SendMessageSuccess (const AString &a_Message)
 
void SendMessageWarning (const AString &a_Message)
 
void SendRotation (double a_YawDegrees, double a_PitchDegrees)
 Sends the "look" packet to the player, forcing them to set their rotation to the specified values. More...
 
void SendSystemMessage (const AString &a_Message)
 
void SendSystemMessage (const cCompositeChat &a_Message)
 
void SetBedPos (Vector3i a_Position)
 Sets the player's bed position to the specified position. More...
 
void SetBedPos (Vector3i a_Position, const cWorld &a_World)
 Sets the player's bed position to the specified position. More...
 
void SetCanFly (bool a_CanFly)
 If true the player can fly even when he's not in creative. More...
 
void SetCrouch (bool a_ShouldCrouch)
 Starts or stops crouching, if our current body stance permits, broadcasting the state change. More...
 
bool SetCurrentExperience (int a_XpTotal)
 Sets the experience total Returns true on success "should" really only be called at init or player death, plugins excepted. More...
 
void SetCustomName (const AString &a_CustomName)
 Sets the custom name of this player. More...
 
void SetDraggingItem (const cItem &a_Item)
 In UI windows, set the item that the player is dragging. More...
 
void SetElytraFlight (bool a_ShouldElytraFly)
 Starts or stops elytra flight, if our current body stance permits, broadcasting the state change. More...
 
void SetFlying (bool a_ShouldFly)
 Starts or stops flying, broadcasting the state change. More...
 
void SetFlyingMaxSpeed (double a_Speed)
 Sets the flying relative maximum speed. More...
 
void SetFoodExhaustionLevel (double a_FoodExhaustionLevel)
 
void SetFoodLevel (int a_FoodLevel)
 
void SetFoodSaturationLevel (double a_FoodSaturationLevel)
 
void SetFoodTickTimer (int a_FoodTickTimer)
 
void SetGameMode (eGameMode a_GameMode)
 Sets the gamemode for the player. More...
 
void SetIsFishing (bool a_IsFishing, UInt32 a_FloaterID=cEntity::INVALID_ID)
 
void SetIsInBed (bool a_IsInBed)
 Sets a player's in-bed state. More...
 
void SetLeftHanded (bool a_IsLeftHanded)
 Sets the dominant hand of the player. More...
 
void SetNormalMaxSpeed (double a_Speed)
 Sets the normal relative maximum speed. More...
 
void SetRespawnPosition (Vector3i a_Position, const cWorld &a_World)
 Sets the player's forced respawn position and world. More...
 
void SetSkinParts (int a_Parts)
 
void SetSprint (bool a_ShouldSprint)
 Starts or stops sprinting, if our current body stance permits, broadcasting the state change. More...
 
void SetSprintingMaxSpeed (double a_Speed)
 Sets the sprinting relative maximum speed. More...
 
void SetTeam (cTeam *a_Team)
 Sets the player team, nullptr if none. More...
 
void SetTouchGround (bool a_bTouchGround)
 
void SetVisible (bool a_bVisible)
 
void SpectateEntity (cEntity *a_Target)
 Spectates the target entity. More...
 
void StartChargingBow (void)
 Starts charging the equipped bow. More...
 
void StartEating (void)
 Starts eating the currently equipped item. More...
 
virtual void TeleportToCoords (double a_PosX, double a_PosY, double a_PosZ) override
 Teleports to the coordinates specified. More...
 
void TossEquippedItem (char a_Amount=1)
 tosses the item in the selected hotbar slot More...
 
void TossHeldItem (char a_Amount=1)
 tosses the item held in hand (when in UI windows) More...
 
void TossItems (const cItems &a_Items)
 Tosses a list of items. More...
 
void TossPickup (const cItem &a_Item)
 tosses a pickup newly created from a_Item More...
 
void Unfreeze ()
 Cancels Freeze(...) and allows the player to move naturally. More...
 
void UpdateCapabilities ()
 Updates player's capabilities - flying, visibility, etc. More...
 
void UpdateMovementStats (const Vector3d &a_DeltaPos, bool a_PreviousIsOnGround)
 Update movement-related statistics. More...
 
cTeamUpdateTeam (void)
 Forces the player to query the scoreboard for his team. More...
 
void UseEquippedItem (cItemHandler::eDurabilityLostAction a_Action)
 Damage the player's equipped item by the amount of damage such an item is damaged by when used for a_Action. More...
 
void UseEquippedItem (short a_Damage=1)
 Damage the player's equipped item by a_Damage, possibly less if the equipped item is enchanted. More...
 
void UseItem (int a_SlotNumber, short a_Damage=1)
 Damage the item in a_SlotNumber by a_Damage, possibly less if the equipped item is enchanted. More...
 
virtual ~cPlayer () override
 
- Public Member Functions inherited from cPawn
void AddEntityEffect (cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier=1)
 Applies an entity effect. More...
 
void ClearEntityEffects (void)
 Removes all currently applied entity effects (used when drinking milk) More...
 
 cPawn (eEntityType a_EntityType, float a_Width, float a_Height)
 
cEntityEffectGetEntityEffect (cEntityEffect::eType a_EffectType) const
 Returns the entity effect, if it is currently applied or nullptr if not. More...
 
std::map< cEntityEffect::eType, cEntityEffect * > GetEntityEffects () const
 Returns all entity effects. More...
 
virtual void HandleAir (void) override
 Called in each tick to handle air-related processing i.e. More...
 
virtual void HandleFalling (void)
 
void HandleFarmlandTrampling (double a_FallHeight, BLOCKTYPE a_BlockAtFoot, BLOCKTYPE a_BlockBelow)
 Handles farmland trampling when hitting the ground. More...
 
bool HasEntityEffect (cEntityEffect::eType a_EffectType) const
 Returns true, if the entity effect is currently applied. More...
 
void NoLongerTargetingMe (cMonster *a_Monster)
 Remove the monster from the list of monsters targeting this pawn. More...
 
void RemoveEntityEffect (cEntityEffect::eType a_EffectType)
 Removes a currently applied entity effect. More...
 
void StopEveryoneFromTargetingMe ()
 Tells all pawns which are targeting us to stop targeting us. More...
 
void TargetingMe (cMonster *a_Monster)
 Add the monster to the list of monsters targeting this pawn. More...
 
- Public Member Functions inherited from cEntity
void AddLeashedMob (cMonster *a_Monster)
 Adds a mob to the leashed list of mobs. More...
 
void AddPosition (const Vector3d &a_AddPos)
 
void AddPosition (double a_AddPosX, double a_AddPosY, double a_AddPosZ)
 
void AddPosX (double a_AddPosX)
 
void AddPosY (double a_AddPosY)
 
void AddPosZ (double a_AddPosZ)
 
void AddSpeed (const Vector3d &a_AddSpeed)
 
void AddSpeed (double a_AddSpeedX, double a_AddSpeedY, double a_AddSpeedZ)
 
void AddSpeedX (double a_AddSpeedX)
 
void AddSpeedY (double a_AddSpeedY)
 
void AddSpeedZ (double a_AddSpeedZ)
 
virtual bool ArmorCoversAgainst (eDamageType a_DamageType)
 Returns whether armor will protect against the specified damage type. More...
 
void AttachTo (cEntity &a_AttachTo)
 Attaches to the specified entity; detaches from any previous one first. More...
 
void BroadcastDeathMessage (TakeDamageInfo &a_TDI)
 Announces a death message on chat about killing the entity. More...
 
 cEntity (eEntityType a_EntityType, Vector3d a_Pos, float a_Width, float a_Height)
 
void Destroy ()
 Destroys the entity, schedules it for memory freeing and broadcasts the DestroyEntity packet. More...
 
void Detach (void)
 Detaches from the currently attached entity, if any. More...
 
virtual void DetectCacti (void)
 Detects the time for application of cacti damage. More...
 
virtual void DetectMagma (void)
 Detects the time for application of magma block damage. More...
 
virtual bool DetectPortal (void)
 Detects whether we are in a portal block and begins teleportation procedures if so Returns true if MoveToWorld() was called, false if not. More...
 
virtual bool DoesPreventBlockPlacement (void) const
 Returns whether blocks can be placed intersecting this entities' hitbox. More...
 
float GetAirDrag (void) const
 
int GetAirLevel (void) const
 Gets remaining air of a monster. More...
 
virtual float GetArmorCoverAgainst (const cEntity *a_Attacker, eDamageType a_DamageType, int a_RawDamage)
 Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover. More...
 
cEntityGetAttached ()
 Gets entity (vehicle) attached to this entity. More...
 
cBoundingBox GetBoundingBox () const
 
int GetChunkX (void) const
 
int GetChunkZ (void) const
 
virtual const char * GetClass (void) const
 Returns the topmost class name for the object. More...
 
virtual void GetDrops (cItems &a_Drops, cEntity *a_Killer=nullptr)
 Returns the list of drops for this pawn when it is killed. More...
 
virtual float GetEnchantmentCoverAgainst (const cEntity *a_Attacker, eDamageType a_DamageType, int a_Damage)
 Returns the hitpoints that the currently equipped armor's enchantments would cover. More...
 
eEntityType GetEntityType (void) const
 
float GetGravity (void) const
 
double GetHeadYaw (void) const
 
float GetHealth (void) const
 Returns the health of this entity. More...
 
float GetHeight (void) const
 
int GetInvulnerableTicks (void) const
 Gets the invulnerable ticks from the entity. More...
 
virtual double GetKnockbackAmountAgainst (const cEntity &a_Receiver)
 Returns the knockback amount that the currently equipped items would cause to a_Receiver on a hit. More...
 
Vector3d GetLastSentPosition (void) const
 Returns the last position we sent to all the clients. More...
 
Vector3d GetLookVector (void) const
 
double GetMass (void) const
 
float GetMaxHealth (void) const
 
cChunkGetParentChunk ()
 Returns the chunk responsible for ticking this entity. More...
 
const cChunkGetParentChunk () const
 
virtual const char * GetParentClass (void) const
 Returns the topmost class's parent class name for the object. More...
 
double GetPitch (void) const
 
const Vector3dGetPosition (void) const
 Exported in ManualBindings. More...
 
double GetPosX (void) const
 
double GetPosY (void) const
 
double GetPosZ (void) const
 
virtual int GetRawDamageAgainst (const cEntity &a_Receiver)
 Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items. More...
 
double GetRoll (void) const
 
const Vector3dGetSpeed (void) const
 Exported in ManualBindings. More...
 
double GetSpeedX (void) const
 
double GetSpeedY (void) const
 
double GetSpeedZ (void) const
 
long int GetTicksAlive (void) const
 Gets number of ticks this entity has been alive for. More...
 
UInt32 GetUniqueID (void) const
 
float GetWidth (void) const
 
cWorldGetWorld (void) const
 
double GetYaw (void) const
 
virtual void HandleSpeedFromAttachee (float a_Forward, float a_Sideways)
 
bool HasAnyMobLeashed () const
 Returs whether the entity has any mob leashed to it. More...
 
bool Initialize (OwnedEntity a_Self, cWorld &a_EntityWorld)
 Spawns the entity in the world; returns true if spawned, false if not (plugin disallowed). More...
 
virtual bool IsA (const char *a_ClassName) const
 Returns true if the entity is of the specified class or a subclass (cPawn's IsA("cEntity") returns true) More...
 
bool IsArrow (void) const
 
bool IsAttachedTo (const cEntity *a_Entity) const
 Returns true if this entity is attached to the specified entity. More...
 
bool IsBoat (void) const
 
bool IsDestroyed () const
 Deprecated. More...
 
bool IsEnderCrystal (void) const
 
bool IsExpOrb (void) const
 
bool IsFallingBlock (void) const
 
bool IsFloater (void) const
 
virtual bool IsHeadInWater (void) const
 Returns true if any part of the entity is in a water block. More...
 
virtual bool IsInFire (void) const
 Returns true if any part of the entity is in a fire block. More...
 
virtual bool IsInLava (void) const
 Returns true if any part of the entity is in a lava block. More...
 
virtual bool IsInWater (void) const
 Returns true if any part of the entity is in a water block. More...
 
bool IsItemFrame (void) const
 
bool IsLeashKnot (void) const
 
bool IsMinecart (void) const
 
bool IsMob (void) const
 
virtual bool IsOnFire (void) const
 
bool IsOrientationDirty () const
 Returns whether the entity's orientation has been set manually. More...
 
bool IsPainting (void) const
 
bool IsPawn (void) const
 
bool IsPickup (void) const
 
bool IsPlayer (void) const
 
bool IsProjectile (void) const
 
virtual bool IsRiding (void) const
 
bool IsTicking (void) const
 Returns true if the entity is valid and ticking. More...
 
bool IsTNT (void) const
 
bool IsWorldChangeScheduled () const
 Returns true if a world change is scheduled to happen. More...
 
bool MoveToWorld (const AString &a_WorldName, bool a_ShouldSendRespawn=true)
 Moves entity to specified world, taking a world name. More...
 
bool MoveToWorld (cWorld &a_World, bool a_ShouldSendRespawn, Vector3d a_NewPosition)
 
bool MoveToWorld (cWorld &a_World, bool a_ShouldSendRespawn=true)
 Moves entity to specified world, taking a world pointer. More...
 
bool MoveToWorld (cWorld &a_World, Vector3d a_NewPosition, bool a_ShouldSetPortalCooldown=false, bool a_ShouldSendRespawn=true)
 
void OnAcquireSpectator (cPlayer &a_Player)
 Called when a player begins spectating this entity. More...
 
virtual void OnFinishedBurning (void)
 Called when the entity finishes burning. More...
 
void OnLoseSpectator (cPlayer &a_Player)
 Called when a player stops spectating this entity. More...
 
virtual void OnRightClicked (cPlayer &a_Player)
 Called when the specified player right-clicks this entity. More...
 
virtual void OnStartedBurning (void)
 Called when the entity starts burning. More...
 
void RemoveLeashedMob (cMonster *a_Monster)
 Removes a mob from the leashed list of mobs. More...
 
void SetAirDrag (float a_AirDrag)
 
void SetGravity (float a_Gravity)
 
void SetHeadYaw (double a_HeadYaw)
 
void SetHealth (float a_Health)
 Sets the health of this entity; doesn't broadcast any hurt animation. More...
 
void SetInvulnerableTicks (int a_InvulnerableTicks)
 Set the invulnerable ticks from the entity. More...
 
void SetIsFireproof (bool a_IsFireproof)
 Sets whether the entity is fireproof. More...
 
void SetIsTicking (bool a_IsTicking)
 Set the entity's status to either ticking or not ticking. More...
 
void SetMass (double a_Mass)
 
void SetMaxHealth (float a_MaxHealth)
 Sets the maximum value for the health. More...
 
void SetParentChunk (cChunk *a_Chunk)
 Sets the parent chunk, which is the chunk responsible for ticking this entity. More...
 
void SetPitch (double a_Pitch)
 
void SetPitchFromSpeed (void)
 Sets the pitch to match the speed vector (entity gies "face-forward") More...
 
void SetPosition (const Vector3d &a_Position)
 
void SetPosition (double a_PosX, double a_PosY, double a_PosZ)
 
void SetPosX (double a_PosX)
 
void SetPosY (double a_PosY)
 
void SetPosZ (double a_PosZ)
 
void SetRoll (double a_Roll)
 
void SetSize (float a_Width, float a_Height)
 Update an entity's size, for example, on body stance changes. More...
 
void SetSpeed (double a_SpeedX, double a_SpeedY, double a_SpeedZ)
 Sets the speed of the entity, measured in m / sec. More...
 
void SetSpeed (Vector3d a_Speed)
 Sets the speed of the entity, measured in m / sec. More...
 
void SetSpeedX (double a_SpeedX)
 Sets the speed in the X axis, leaving the other speed components intact. More...
 
void SetSpeedY (double a_SpeedY)
 Sets the speed in the Y axis, leaving the other speed components intact. More...
 
void SetSpeedZ (double a_SpeedZ)
 Sets the speed in the Z axis, leaving the other speed components intact. More...
 
void SetWorld (cWorld *a_World)
 Sets the internal world pointer to a new cWorld, doesn't update anything else. More...
 
void SetYaw (double a_Yaw)
 
void SetYawFromSpeed (void)
 Sets the rotation to match the speed vector (entity goes "face-forward") More...
 
void StartBurning (int a_TicksLeftBurning)
 Puts the entity on fire for the specified amount of ticks. More...
 
void SteerVehicle (float a_Forward, float a_Sideways)
 
void StopBurning (void)
 Stops the entity from burning, resets all burning timers. More...
 
void TakeDamage (cEntity &a_Attacker)
 Makes this pawn take damage from an attack by a_Attacker. More...
 
void TakeDamage (eDamageType a_DamageType, cEntity *a_Attacker, int a_RawDamage, double a_KnockbackAmount)
 Makes this entity take the specified damage. More...
 
void TakeDamage (eDamageType a_DamageType, cEntity *a_Attacker, int a_RawDamage, float a_FinalDamage, double a_KnockbackAmount)
 Makes this entity take the specified damage. More...
 
void TakeDamage (eDamageType a_DamageType, UInt32 a_Attacker, int a_RawDamage, double a_KnockbackAmount)
 Makes this entity take the specified damage. More...
 
virtual void TeleportToEntity (cEntity &a_Entity)
 Teleports to the entity specified. More...
 
virtual void TickBurning (cChunk &a_Chunk)
 Updates the state related to this entity being on fire. More...
 
virtual void TickInVoid (cChunk &a_Chunk)
 Handles when the entity is in the void. More...
 
void WrapHeadYaw ()
 Makes sure head yaw is not over the specified range. More...
 
void WrapRotation ()
 Makes sure rotation is not over the specified range. More...
 
void WrapSpeed ()
 Makes speed is not over 20. More...
 
virtual ~cEntity ()=default
 

Static Public Member Functions

static int CalcLevelFromXp (int a_CurrentXp)
 Inverse of XpForLevel Ref: https://minecraft.gamepedia.com/XP values are as per this with pre-calculations. More...
 
static bool PermissionMatches (const AStringVector &a_Permission, const AStringVector &a_Template)
 Returns true iff a_Permission matches the a_Template. More...
 
static int XpForLevel (int a_Level)
 Calculates the amount of XP needed for a given level Ref: https://minecraft.gamepedia.com/XP. More...
 
- Static Public Member Functions inherited from cPawn
static bool FindTeleportDestination (cWorld &a_World, const int a_HeightRequired, const unsigned int a_NumTries, Vector3d &a_Destination, const cBoundingBox a_BoundingBox)
 
static bool FindTeleportDestination (cWorld &a_World, const int a_HeightRequired, const unsigned int a_NumTries, Vector3d &a_Destination, const Vector3i a_MinBoxCorner, const Vector3i a_MaxBoxCorner)
 
static bool FindTeleportDestination (cWorld &a_World, const int a_HeightRequired, const unsigned int a_NumTries, Vector3d &a_Destination, Vector3i a_Centre, const int a_HalfCubeWidth)
 Used by enderman and chorus fruit. More...
 
- Static Public Member Functions inherited from cEntity
static const char * GetClassStatic (void)
 Returns the class name of this class. More...
 

Static Public Attributes

static const int MAX_FOOD_LEVEL = 20
 
static const int MAX_HEALTH = 20
 
- Static Public Attributes inherited from cEntity
static const int BURN_DAMAGE = 1
 Damage to deal when the entity is burning. More...
 
static const int BURN_TICKS = 160
 Ticks to keep an entity burning after it has stood in lava / fire. More...
 
static const int BURN_TICKS_PER_DAMAGE = 20
 Ticks to wait between damaging an entity when it is burning. More...
 
static const int DROWNING_TICKS = 20
 Number of ticks per heart of damage. More...
 
static const int FALL_DAMAGE_HEIGHT = 4
 Y difference after which fall damage is applied. More...
 
static const int FIRE_DAMAGE = 1
 Damage to deal when standing in fire. More...
 
static const int FIRE_TICKS_PER_DAMAGE = 10
 Ticks to wait between damaging an entity when it stands in fire. More...
 
static const UInt32 INVALID_ID = 0
 Special ID that is considered an "invalid value", signifying no entity. More...
 
static const int LAVA_DAMAGE = 4
 Damage to deal when standing in lava. More...
 
static const int LAVA_TICKS_PER_DAMAGE = 10
 Ticks to wait between damaging an entity when it stands in lava. More...
 
static const int MAX_AIR_LEVEL = 300
 Maximum air an entity can have. More...
 
static const int VOID_BOUNDARY = -64
 Y position to begin applying void damage. More...
 

Private Types

typedef std::vector< std::vector< AString > > AStringVectorVector
 
using Super = cPawn
 

Private Member Functions

void AddKnownRecipe (UInt32 RecipeId)
 Add the recipe Id to the known recipes. More...
 
virtual void ApplyArmorDamage (int DamageBlocked) override
 Applies damage to the armor after the armor blocked the given amount. More...
 
virtual void BroadcastMovementUpdate (const cClientHandle *a_Exclude=nullptr) override
 Updates clients of changes in the entity. More...
 
virtual bool DoTakeDamage (TakeDamageInfo &TDI) override
 Makes this entity take damage specified in the a_TDI. More...
 
void FreezeInternal (const Vector3d &a_Location, bool a_ManuallyFrozen)
 Pins the player to a_Location until Unfreeze() is called. More...
 
float GetDigSpeed (BLOCKTYPE a_Block)
 Returns the dig speed using the current tool on the block a_Block. More...
 
virtual float GetEnchantmentBlastKnockbackReduction () override
 Returns explosion knock back reduction percent from blast protection level. More...
 
float GetLiquidHeightPercent (NIBBLETYPE a_Meta)
 Returns how high the liquid is in percent. More...
 
AString GetUUIDFileName (const cUUID &a_UUID)
 Returns the filename for the player data based on the UUID given. More...
 
void HandleFloater (void)
 Called in each tick if the player is fishing to make sure the floater dissapears when the player doesn't have a fishing rod as equipped item. More...
 
void HandleFood (void)
 Called in each tick to handle food-related processing. More...
 
virtual void HandlePhysics (std::chrono::milliseconds a_Dt, cChunk &) override
 Handles the physics of the entity - updates position based on speed, updates speed based on environment. More...
 
virtual bool IsElytraFlying (void) const override
 
bool IsInsideWater ()
 Checks if the player is inside of water. More...
 
virtual bool IsInvisible () const override
 
virtual bool IsRclking (void) const override
 
virtual void OnAddToWorld (cWorld &a_World) override
 Called when the entity is added to a world. More...
 
virtual void OnDetach () override
 Called when this entity dismounts from m_AttachedTo. More...
 
virtual void OnRemoveFromWorld (cWorld &a_World) override
 Called when the entity is removed from a world. More...
 
void RefreshRank ()
 (Re)loads the rank and permissions from the cRankManager. More...
 
virtual void SpawnOn (cClientHandle &a_Client) override
 Descendants override this function to send a command to the specified client to spawn the entity on the client. More...
 
virtual void Tick (std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
 
void TickFreezeCode ()
 

Private Attributes

std::variant< BodyStanceCrouching, BodyStanceSleeping, BodyStanceSprinting, BodyStanceStanding, BodyStanceGlidingm_BodyStance
 The current body stance the player has adopted. More...
 
int m_BowCharge
 
std::shared_ptr< cClientHandlem_ClientHandle
 
cWindowm_CurrentWindow
 
std::string m_CurrentWorldName
 The name of the world which the player currently resides in. More...
 
int m_CurrentXp
 
AString m_CustomName
 
std::string m_DefaultWorldPath
 The save path of the default world. More...
 
cItem m_DraggingItem
 The item being dragged by the cursor while in a UI window. More...
 
cTickTimeLong m_EatingFinishTick
 The world tick in which eating will be finished. More...
 
unsigned int m_EnchantmentSeed
 
cItemGrid m_EnderChestContents
 An item grid that stores the player specific enderchest contents. More...
 
UInt32 m_FloaterID
 
double m_FlyingMaxSpeed
 Max speed, relative to the game default flying max speed, when flying. More...
 
double m_FoodExhaustionLevel
 A "buffer" which adds up hunger before it is substracted from m_FoodSaturationLevel or m_FoodLevel. More...
 
int m_FoodLevel
 Represents the food bar, one point equals half a "drumstick". More...
 
double m_FoodSaturationLevel
 "Overcharge" for the m_FoodLevel; is depleted before m_FoodLevel More...
 
int m_FoodTickTimer
 Count-up to the healing or damaging action, based on m_FoodLevel. More...
 
eGameMode m_GameMode
 
cInventory m_Inventory
 Stores the player's inventory, consisting of crafting grid, hotbar, and main slots. More...
 
cSlotNums m_InventoryPaintSlots
 
cWindowm_InventoryWindow
 
bool m_IsChargingBow
 
bool m_IsFishing
 
bool m_IsFlightCapable
 If this is true the player can fly. More...
 
bool m_IsFlying
 
bool m_IsFrozen
 If true, we are locking m_Position to m_FrozenPosition. More...
 
bool m_IsLeftHanded
 Whether the player is left-handed, or right-handed. More...
 
bool m_IsManuallyFrozen
 Was the player frozen manually by a plugin or automatically by the server? More...
 
bool m_IsRespawnPointForced
 Whether we unconditionally respawn to m_RespawnPosition, or check if a bed is unobstructed and available first. More...
 
bool m_IsTeleporting
 Flag used by food handling system to determine whether a teleport has just happened. More...
 
bool m_IsVisible
 
std::set< cItem, cItem::sItemComparem_KnownItems
 List of known items as Ids. More...
 
std::set< UInt32m_KnownRecipes
 List on known recipes as Ids. More...
 
int m_LifetimeTotalXp
 Player Xp level. More...
 
AString m_MsgNameColorCode
 
AString m_MsgPrefix
 
AString m_MsgSuffix
 
double m_NormalMaxSpeed
 Max speed, relative to the game default. More...
 
AStringVector m_Permissions
 All the permissions that this player has, based on their rank. More...
 
AString m_Rank
 The name of the rank assigned to this player. More...
 
Vector3i m_RespawnPosition
 The player's potential respawn position, initialised to world spawn by default. More...
 
AStringVector m_Restrictions
 All the restrictions that this player has, based on their rank. More...
 
int m_SkinParts
 Displayed skin part bit mask. More...
 
std::string m_SpawnWorldName
 The name of the world which the player respawns in upon death. More...
 
cEntitym_Spectating
 The entity that this player is spectating, nullptr if none. More...
 
AStringVectorVector m_SplitPermissions
 All the permissions that this player has, based on their rank, split into individual dot-delimited parts. More...
 
AStringVectorVector m_SplitRestrictions
 All the restrictions that this player has, based on their rank, split into individual dot-delimited parts. More...
 
double m_SprintingMaxSpeed
 Max speed, relative to the game default max speed, when sprinting. More...
 
StatisticsManager m_Stats
 
cTeamm_Team
 
unsigned int m_TicksUntilNextSave
 How long till the player's inventory will be saved Default save interval is #defined in PLAYER_INVENTORY_SAVE_INTERVAL. More...
 

Additional Inherited Members

- Public Types inherited from cEntity
enum  eEntityType {
  etEntity, etEnderCrystal, etPlayer, etPickup,
  etMonster, etFallingBlock, etMinecart, etBoat,
  etTNT, etProjectile, etExpOrb, etFloater,
  etItemFrame, etPainting, etLeashKnot, etMob = etMonster
}
 
- Protected Types inherited from cPawn
typedef std::map< cEntityEffect::eType, std::unique_ptr< cEntityEffect > > tEffectMap
 
- Protected Member Functions inherited from cPawn
virtual void ResetPosition (Vector3d a_NewPosition) override
 Set the entities position and last sent position. More...
 
- Protected Member Functions inherited from cEntity
void BroadcastLeashedMobs ()
 If has any mobs are leashed, broadcasts every leashed entity to this. More...
 
void DoMoveToWorld (const sWorldChangeInfo &a_WorldChangeInfo)
 Handles the moving of this entity between worlds. More...
 
virtual void SetSwimState (cChunk &a_Chunk)
 Called once per tick to set m_IsInFire, m_IsInLava, m_IsInWater and m_IsHeadInWater. More...
 
- Static Protected Member Functions inherited from cEntity
static void ApplyFriction (Vector3d &a_Speed, double a_SlowdownMultiplier, float a_Dt)
 Applies friction to an entity. More...
 
- Protected Attributes inherited from cPawn
bool m_bTouchGround
 
tEffectMap m_EntityEffects
 
double m_LastGroundHeight
 
- Protected Attributes inherited from cEntity
float m_AirDrag
 Stores the air drag that is applied to the entity every tick, measured in speed ratio per tick Acts as air friction and slows down flight Will be interpolated if the server tick rate varies Data: https://minecraft.gamepedia.com/Entity#Motion_of_entities. More...
 
int m_AirLevel
 Air level of a mobile. More...
 
int m_AirTickTimer
 
cEntitym_AttachedTo
 The entity to which this entity is attached (vehicle), nullptr if none. More...
 
cEntitym_Attachee
 The entity which is attached to this entity (rider), nullptr if none. More...
 
bool m_bDirtyHead
 Stores whether head yaw has been set manually. More...
 
bool m_bDirtyOrientation
 Stores whether our yaw / pitch / roll (body orientation) has been set manually. More...
 
bool m_bHasSentNoSpeed
 Stores whether we have sent a Velocity packet with a speed of zero (no speed) to the client Ensures that said packet is sent only once. More...
 
bool m_bOnGround
 Stores if the entity is on the ground. More...
 
eEntityType m_EntityType
 
float m_Gravity
 Stores gravity that is applied to an entity every tick For realistic effects, this should be negative. More...
 
float m_Health
 
bool m_IsFireproof
 Whether the entity is capable of taking fire or lava damage. More...
 
bool m_IsHeadInWater
 If the entity's head is in a water block. More...
 
bool m_IsInFire
 If any part of the entity is in a fire block. More...
 
bool m_IsInLava
 If any part of the entity is in a lava block. More...
 
bool m_IsInWater
 If any part of the entity is in a water block. More...
 
Vector3d m_LastPosition
 
Vector3d m_LastSentPosition
 Last position sent to client via the Relative Move or Teleport packets (not Velocity) Only updated if cEntity::BroadcastMovementUpdate() is called! More...
 
float m_MaxHealth
 
sPortalCooldownData m_PortalCooldownData
 Portal delay timer and cooldown boolean data. More...
 
Vector3d m_Speed
 Measured in meters / second (m / s) More...
 
long int m_TicksAlive
 The number of ticks this entity has been alive for. More...
 
int m_TicksLeftBurning
 Time, in ticks, until the entity extinguishes its fire. More...
 
int m_TicksSinceLastBurnDamage
 Time, in ticks, since the last damage dealt by being on fire. More...
 
int m_TicksSinceLastFireDamage
 Time, in ticks, since the last damage dealt by standing in fire. More...
 
int m_TicksSinceLastLavaDamage
 Time, in ticks, since the last damage dealt by standing in lava. More...
 
int m_TicksSinceLastVoidDamage
 Time, in ticks, since the last damage dealt by the void. More...
 
UInt32 m_UniqueID
 The ID of the entity that is guaranteed to be unique within a single run of the server. More...
 
cWorldm_World
 
sWorldChangeInfo m_WorldChangeInfo
 If field m_NewWorld not nullptr, a world change is scheduled and a task is queued in the current world. More...
 

Detailed Description

Definition at line 27 of file Player.h.

Member Typedef Documentation

◆ AStringVectorVector

typedef std::vector<std::vector<AString> > cPlayer::AStringVectorVector
private

Definition at line 609 of file Player.h.

◆ Super

using cPlayer::Super = cPawn
private

Definition at line 32 of file Player.h.

Constructor & Destructor Documentation

◆ cPlayer()

cPlayer::cPlayer ( const std::shared_ptr< cClientHandle > &  a_Client)

Definition at line 117 of file Player.cpp.

◆ ~cPlayer()

cPlayer::~cPlayer ( )
overridevirtual

Definition at line 155 of file Player.cpp.

Member Function Documentation

◆ AbortEating()

void cPlayer::AbortEating ( void  )

Aborts the current eating operation.

Definition at line 551 of file Player.cpp.

◆ AddFoodExhaustion()

void cPlayer::AddFoodExhaustion ( double  a_Exhaustion)

Adds the specified exhaustion to m_FoodExhaustion.

Expects only positive values.

Definition at line 439 of file Player.cpp.

◆ AddInventoryPaintSlot()

void cPlayer::AddInventoryPaintSlot ( int  a_SlotNum)

Adds a slot to the list for inventory painting.

To be used by cWindow only

Definition at line 571 of file Player.cpp.

◆ AddKnownItem()

void cPlayer::AddKnownItem ( const cItem a_Item)

Adds an Item to the list of known items.

If the item is already known, does nothing.

Definition at line 2708 of file Player.cpp.

◆ AddKnownRecipe()

void cPlayer::AddKnownRecipe ( UInt32  RecipeId)
private

Add the recipe Id to the known recipes.

If the recipe is already known, does nothing.

Definition at line 2734 of file Player.cpp.

◆ ApplyArmorDamage()

void cPlayer::ApplyArmorDamage ( int  DamageBlocked)
overrideprivatevirtual

Applies damage to the armor after the armor blocked the given amount.

Reimplemented from cEntity.

Definition at line 2848 of file Player.cpp.

◆ AwardAchievement()

void cPlayer::AwardAchievement ( CustomStatistic  a_Ach)

Awards the player an achievement.

If all prerequisites are met, this method will award the achievement and will broadcast a chat message. If the achievement has been already awarded to the player, this method will just increment the stat counter.

Definition at line 1372 of file Player.cpp.

◆ BroadcastMovementUpdate()

void cPlayer::BroadcastMovementUpdate ( const cClientHandle a_Exclude = nullptr)
overrideprivatevirtual

Updates clients of changes in the entity.

Reimplemented from cEntity.

Definition at line 2862 of file Player.cpp.

◆ CalcLevelFromXp()

int cPlayer::CalcLevelFromXp ( int  a_CurrentXp)
static

Inverse of XpForLevel Ref: https://minecraft.gamepedia.com/XP values are as per this with pre-calculations.

Definition at line 184 of file Player.cpp.

◆ CancelChargingBow()

void cPlayer::CancelChargingBow ( void  )

Cancels the current bow charging.

Definition at line 339 of file Player.cpp.

◆ CanFly()

virtual bool cPlayer::CanFly ( void  ) const
inlinevirtual

Returns wheter the player can fly or not.

Definition at line 549 of file Player.h.

◆ CanInstantlyMine()

bool cPlayer::CanInstantlyMine ( BLOCKTYPE  a_Block)

Given tool, enchantments, status effects, and world position returns whether a_Block would be instantly mined.

Depends on hardness values so check those are correct. Source: https://minecraft.gamepedia.com/Breaking#Instant_breaking

Definition at line 2696 of file Player.cpp.

◆ CanMobsTarget()

bool cPlayer::CanMobsTarget ( void  ) const

Returns true if the player can be targeted by Mobs.

Definition at line 1061 of file Player.cpp.

◆ ClearInventoryPaintSlots()

void cPlayer::ClearInventoryPaintSlots ( void  )

Clears the list of slots that are being inventory-painted.

To be used by cWindow only

Definition at line 561 of file Player.cpp.

◆ CloseWindow()

void cPlayer::CloseWindow ( bool  a_CanRefuse = true)

Closes the current window, resets current window to m_InventoryWindow.

A plugin may refuse the closing if a_CanRefuse is true

Definition at line 1144 of file Player.cpp.

◆ CloseWindowIfID()

void cPlayer::CloseWindowIfID ( char  a_WindowID,
bool  a_CanRefuse = true 
)

Closes the current window if it matches the specified ID, resets current window to m_InventoryWindow.

Definition at line 1169 of file Player.cpp.

◆ DeltaExperience()

int cPlayer::DeltaExperience ( int  a_Xp_delta)

Definition at line 279 of file Player.cpp.

◆ DoesPlacingBlocksIntersectEntity()

bool cPlayer::DoesPlacingBlocksIntersectEntity ( std::initializer_list< sSetBlock a_Blocks) const

Whether placing the given blocks would intersect any entitiy.

Definition at line 2366 of file Player.cpp.

◆ DoTakeDamage()

bool cPlayer::DoTakeDamage ( TakeDamageInfo a_TDI)
overrideprivatevirtual

Makes this entity take damage specified in the a_TDI.

The TDI is sent through plugins first, then applied. If it returns false, the entity hasn't receive any damage.

Reimplemented from cEntity.

Definition at line 2881 of file Player.cpp.

◆ Feed()

bool cPlayer::Feed ( int  a_Food,
double  a_Saturation 
)

Adds to FoodLevel and FoodSaturationLevel, returns true if any food has been consumed, false if player "full".

Definition at line 423 of file Player.cpp.

◆ FinishChargingBow()

int cPlayer::FinishChargingBow ( void  )

Finishes charging the current bow.

Returns the number of ticks for which the bow has been charged

Definition at line 324 of file Player.cpp.

◆ FinishEating()

void cPlayer::FinishEating ( void  )

Finishes eating the currently equipped item.

Consumes the item, updates health and broadcasts the packets

Definition at line 527 of file Player.cpp.

◆ ForceSetSpeed()

void cPlayer::ForceSetSpeed ( const Vector3d a_Speed)

Forces the player to move in the given direction.

Deprecated:
Use SetSpeed instead.

Definition at line 1540 of file Player.cpp.

◆ Freeze()

void cPlayer::Freeze ( const Vector3d a_Location)

Prevent the player from moving and lock him into a_Location.

Definition at line 1423 of file Player.cpp.

◆ FreezeInternal()

void cPlayer::FreezeInternal ( const Vector3d a_Location,
bool  a_ManuallyFrozen 
)
private

Pins the player to a_Location until Unfreeze() is called.

If ManuallyFrozen is false, the player will unfreeze when the chunk is loaded.

Definition at line 2530 of file Player.cpp.

◆ GetClientHandle()

cClientHandle* cPlayer::GetClientHandle ( void  ) const
inline

Definition at line 276 of file Player.h.

◆ GetColor()

AString cPlayer::GetColor ( void  ) const

Returns the full color code to use for this player, based on their rank.

The returned value either is empty, or includes the cChatColor::Delimiter.

Definition at line 1651 of file Player.cpp.

◆ GetCurrentXp()

int cPlayer::GetCurrentXp ( void  )
inline

Gets the current experience.

Definition at line 117 of file Player.h.

◆ GetCustomName()

const AString& cPlayer::GetCustomName ( void  ) const
inline

Returns the custom name of this player.

If the player hasn't a custom name, it will return an empty string.

Definition at line 508 of file Player.h.

◆ GetDigSpeed()

float cPlayer::GetDigSpeed ( BLOCKTYPE  a_Block)
private

Returns the dig speed using the current tool on the block a_Block.

Returns one if using hand. If the player is using a tool that is good to break the block the value is higher. If he has an enchanted tool with efficiency or he has a haste or mining fatique effect it gets multiplied by a specific factor depending on the strength of the effect or enchantment. In he is in water it gets divided by 5 except if his tool is enchanted with aqua affinity. If he is not on ground it also gets divided by 5. Source: https://minecraft.gamepedia.com/Breaking#Calculation

Definition at line 2607 of file Player.cpp.

◆ GetDraggingItem()

cItem& cPlayer::GetDraggingItem ( void  )
inline

In UI windows, get the item that the player is dragging.

Definition at line 448 of file Player.h.

◆ GetEffectiveGameMode()

eGameMode cPlayer::GetEffectiveGameMode ( void  ) const

Returns the current effective gamemode (inherited gamemode is resolved before returning)

Definition at line 1531 of file Player.cpp.

◆ GetEnchantmentBlastKnockbackReduction()

float cPlayer::GetEnchantmentBlastKnockbackReduction ( )
overrideprivatevirtual

Returns explosion knock back reduction percent from blast protection level.

Returns
knock back reduce percent

Reimplemented from cEntity.

Definition at line 2932 of file Player.cpp.

◆ GetEnchantmentRandomProvider()

MTRand cPlayer::GetEnchantmentRandomProvider ( )

Get a copy of the PRNG for enchanting related generation, don't use this for other purposes.

The PRNG's state is initialised with an internal seed, such that until PermuteEnchantmentSeed is called, this function returns the same PRNG.

Definition at line 1567 of file Player.cpp.

◆ GetEnderChestContents()

cItemGrid& cPlayer::GetEnderChestContents ( void  )
inline

Gets the contents of the player's associated enderchest.

Definition at line 160 of file Player.h.

◆ GetEquippedBoots()

virtual cItem cPlayer::GetEquippedBoots ( void  ) const
inlineoverridevirtual

Returns the currently equipped boots; empty item if none.

Reimplemented from cEntity.

Definition at line 601 of file Player.h.

◆ GetEquippedChestplate()

virtual cItem cPlayer::GetEquippedChestplate ( void  ) const
inlineoverridevirtual

Returns the currently equipped chestplate; empty item if none.

Reimplemented from cEntity.

Definition at line 599 of file Player.h.

◆ GetEquippedHelmet()

virtual cItem cPlayer::GetEquippedHelmet ( void  ) const
inlineoverridevirtual

Returns the currently equipped helmet; empty item if none.

Reimplemented from cEntity.

Definition at line 598 of file Player.h.

◆ GetEquippedItem()

const cItem& cPlayer::GetEquippedItem ( void  ) const
inline

Definition at line 162 of file Player.h.

◆ GetEquippedLeggings()

virtual cItem cPlayer::GetEquippedLeggings ( void  ) const
inlineoverridevirtual

Returns the currently equipped leggings; empty item if none.

Reimplemented from cEntity.

Definition at line 600 of file Player.h.

◆ GetEquippedWeapon()

virtual cItem cPlayer::GetEquippedWeapon ( void  ) const
inlineoverridevirtual

Returns the curently equipped weapon; empty item if none.

Reimplemented from cEntity.

Definition at line 597 of file Player.h.

◆ GetEyeHeight()

double cPlayer::GetEyeHeight ( void  ) const

Definition at line 992 of file Player.cpp.

◆ GetEyePosition()

Vector3d cPlayer::GetEyePosition ( void  ) const

Definition at line 1001 of file Player.cpp.

◆ GetFloaterID()

UInt32 cPlayer::GetFloaterID ( void  ) const
inline

Definition at line 390 of file Player.h.

◆ GetFlyingMaxSpeed()

double cPlayer::GetFlyingMaxSpeed ( void  ) const
inline

Gets the flying relative maximum speed.

Definition at line 475 of file Player.h.

◆ GetFoodExhaustionLevel()

double cPlayer::GetFoodExhaustionLevel ( void  ) const
inline

Definition at line 357 of file Player.h.

◆ GetFoodLevel()

int cPlayer::GetFoodLevel ( void  ) const
inline

Definition at line 354 of file Player.h.

◆ GetFoodSaturationLevel()

double cPlayer::GetFoodSaturationLevel ( void  ) const
inline

Definition at line 355 of file Player.h.

◆ GetFoodTickTimer()

int cPlayer::GetFoodTickTimer ( void  ) const
inline

Definition at line 356 of file Player.h.

◆ GetGameMode()

eGameMode cPlayer::GetGameMode ( void  ) const
inline

Returns the current gamemode.

Partly OBSOLETE, you should use IsGameModeXXX() functions wherever applicable

Definition at line 199 of file Player.h.

◆ GetInventory() [1/2]

cInventory& cPlayer::GetInventory ( void  )
inline

Definition at line 156 of file Player.h.

◆ GetInventory() [2/2]

const cInventory& cPlayer::GetInventory ( void  ) const
inline

Definition at line 157 of file Player.h.

◆ GetInventoryPaintSlots()

const cSlotNums & cPlayer::GetInventoryPaintSlots ( void  ) const

Returns the list of slots currently stored for inventory painting.

To be used by cWindow only

Definition at line 581 of file Player.cpp.

◆ GetIP()

AString cPlayer::GetIP ( void  ) const

Definition at line 1070 of file Player.cpp.

◆ GetKnownRecipes()

const std::set< UInt32 > & cPlayer::GetKnownRecipes ( ) const

Gets the set of IDs for recipes this player has discovered.

Definition at line 206 of file Player.cpp.

◆ GetLastBedPos()

Vector3i cPlayer::GetLastBedPos ( void  ) const
inline

Gets the player's potential respawn position (named LastBedPos for compatibility reasons).

Definition at line 515 of file Player.h.

◆ GetLiquidHeightPercent()

float cPlayer::GetLiquidHeightPercent ( NIBBLETYPE  a_Meta)
private

Returns how high the liquid is in percent.

Used by IsInsideWater

Definition at line 2565 of file Player.cpp.

◆ GetLoadedWorldName()

const AString& cPlayer::GetLoadedWorldName ( ) const
inline

Definition at line 429 of file Player.h.

◆ GetMaxSpeed()

double cPlayer::GetMaxSpeed ( void  ) const

Returns the current relative maximum speed (takes current sprinting / flying state into account)

Definition at line 591 of file Player.cpp.

◆ GetMiningProgressPerTick()

float cPlayer::GetMiningProgressPerTick ( BLOCKTYPE  a_Block)

Returns the progress mined per tick for the block a_Block as a fraction (1 would be completely mined) Depends on hardness values so check those are correct.

Source: https://minecraft.gamepedia.com/Breaking#Calculation

Definition at line 2673 of file Player.cpp.

◆ GetName()

const AString & cPlayer::GetName ( void  ) const

Definition at line 1299 of file Player.cpp.

◆ GetNormalMaxSpeed()

double cPlayer::GetNormalMaxSpeed ( void  ) const
inline

Gets the normal relative maximum speed.

Definition at line 469 of file Player.h.

◆ GetOffHandEquipedItem()

virtual cItem cPlayer::GetOffHandEquipedItem ( void  ) const
inlineoverridevirtual

Returns the currently offhand equipped item; empty item if none.

Reimplemented from cEntity.

Definition at line 602 of file Player.h.

◆ GetPermissions()

const AStringVector& cPlayer::GetPermissions ( void  ) const
inline

Returns all the permissions that the player has assigned to them.

Definition at line 315 of file Player.h.

◆ GetPlayerListName()

AString cPlayer::GetPlayerListName ( void  ) const

Returns the name that is used in the playerlist.

Definition at line 1685 of file Player.cpp.

◆ GetPrefix()

AString cPlayer::GetPrefix ( void  ) const

Returns the player name prefix, may contain @ format directives.

Definition at line 1667 of file Player.cpp.

◆ GetRespawnWorld()

cWorld * cPlayer::GetRespawnWorld ( )

Definition at line 817 of file Player.cpp.

◆ GetRestrictions()

const AStringVector& cPlayer::GetRestrictions ( void  ) const
inline

Returns all the restrictions that the player has assigned to them.

Definition at line 318 of file Player.h.

◆ GetSkinParts()

int cPlayer::GetSkinParts ( void  ) const
inline

Definition at line 560 of file Player.h.

◆ GetSprintingMaxSpeed()

double cPlayer::GetSprintingMaxSpeed ( void  ) const
inline

Gets the sprinting relative maximum speed.

Definition at line 472 of file Player.h.

◆ GetStatistics()

StatisticsManager& cPlayer::GetStatistics ( )
inline

Return the associated statistic and achievement manager.

Definition at line 237 of file Player.h.

◆ GetSuffix()

AString cPlayer::GetSuffix ( void  ) const

Returns the player name suffix, may contain @ format directives.

Definition at line 1676 of file Player.cpp.

◆ GetTeam() [1/2]

cTeam* cPlayer::GetTeam ( void  )
inline

Returns the associated team, nullptr if none.

Definition at line 240 of file Player.h.

◆ GetTeam() [2/2]

const cTeam* cPlayer::GetTeam ( void  ) const
inline

Returns the associated team, nullptr if none.

Definition at line 243 of file Player.h.

◆ GetThrowSpeed()

Vector3d cPlayer::GetThrowSpeed ( double  a_SpeedCoeff) const

Returns the initial speed vector of a throw, with a 3D length of a_SpeedCoeff.

Definition at line 1517 of file Player.cpp.

◆ GetThrowStartPos()

Vector3d cPlayer::GetThrowStartPos ( void  ) const

Returns the position where projectiles thrown by this player should start, player eye position + adjustment.

Definition at line 1501 of file Player.cpp.

◆ GetUUID()

const cUUID & cPlayer::GetUUID ( void  ) const

Returns the UUID that has been read from the client, or nil if not available.

Definition at line 2431 of file Player.cpp.

◆ GetUUIDFileName()

AString cPlayer::GetUUIDFileName ( const cUUID a_UUID)
private

Returns the filename for the player data based on the UUID given.

This can be used both for online and offline UUIDs.

Definition at line 2514 of file Player.cpp.

◆ GetWindow() [1/2]

cWindow* cPlayer::GetWindow ( void  )
inline

Definition at line 262 of file Player.h.

◆ GetWindow() [2/2]

const cWindow* cPlayer::GetWindow ( void  ) const
inline

Definition at line 263 of file Player.h.

◆ GetXpLevel()

int cPlayer::GetXpLevel ( void  ) const

Gets the current level - XpLevel.

Definition at line 237 of file Player.cpp.

◆ GetXpLifetimeTotal()

int cPlayer::GetXpLifetimeTotal ( void  )
inline

Gets the experience total - XpTotal for score on death.

Definition at line 114 of file Player.h.

◆ GetXpPercentage()

float cPlayer::GetXpPercentage ( void  ) const

Gets the experience bar percentage - XpP.

Definition at line 246 of file Player.cpp.

◆ HandleFloater()

void cPlayer::HandleFloater ( void  )
private

Called in each tick if the player is fishing to make sure the floater dissapears when the player doesn't have a fishing rod as equipped item.

Definition at line 2172 of file Player.cpp.

◆ HandleFood()

void cPlayer::HandleFood ( void  )
private

Called in each tick to handle food-related processing.

Definition at line 2116 of file Player.cpp.

◆ HandlePhysics()

virtual void cPlayer::HandlePhysics ( std::chrono::milliseconds  a_Dt,
cChunk a_Chunk 
)
inlineoverrideprivatevirtual

Handles the physics of the entity - updates position based on speed, updates speed based on environment.

Reimplemented from cEntity.

Definition at line 800 of file Player.h.

◆ HasCustomName()

bool cPlayer::HasCustomName ( void  ) const
inline

Returns true if the player has a custom name.

Definition at line 505 of file Player.h.

◆ HasPermission()

bool cPlayer::HasPermission ( const AString a_Permission) const

Definition at line 1586 of file Player.cpp.

◆ HasSkinPart()

bool cPlayer::HasSkinPart ( eSkinPart  a_Part) const
inline

Definition at line 559 of file Player.h.

◆ Heal()

void cPlayer::Heal ( int  a_Health)
overridevirtual

Heals the player by the specified amount of HPs (positive only); sends health update.

Reimplemented from cEntity.

Definition at line 369 of file Player.cpp.

◆ IsChargingBow()

bool cPlayer::IsChargingBow ( void  ) const
inline

Returns true if the player is currently charging the bow.

Definition at line 151 of file Player.h.

◆ IsClimbing()

bool cPlayer::IsClimbing ( void  ) const

Returns whether the player is climbing (ladders, vines etc.)

Definition at line 2191 of file Player.cpp.

◆ IsCrouched()

bool cPlayer::IsCrouched ( void  ) const
overridevirtual

Reimplemented from cEntity.

Definition at line 2949 of file Player.cpp.

◆ IsEating()

bool cPlayer::IsEating ( void  ) const
inline

Returns true if the player is currently in the process of eating the currently equipped item.

Definition at line 374 of file Player.h.

◆ IsElytraFlying()

bool cPlayer::IsElytraFlying ( void  ) const
overrideprivatevirtual

Reimplemented from cEntity.

Definition at line 2967 of file Player.cpp.

◆ IsFireproof()

virtual bool cPlayer::IsFireproof ( ) const
inlineoverridevirtual

Returns true if the player is fireproof Stops players burning in creative or spectator modes.

Reimplemented from cPawn.

Definition at line 225 of file Player.h.

◆ IsFishing()

bool cPlayer::IsFishing ( void  ) const
inline

Returns true if the player has thrown out a floater.

Definition at line 386 of file Player.h.

◆ IsFlying()

bool cPlayer::IsFlying ( void  ) const
inline

Returns true if the player is currently flying.

Definition at line 377 of file Player.h.

◆ IsFrozen()

bool cPlayer::IsFrozen ( )

Is the player frozen?

Definition at line 1432 of file Player.cpp.

◆ IsGameModeAdventure()

bool cPlayer::IsGameModeAdventure ( void  ) const

Returns true if the player is in Adventure mode, either explicitly, or by inheriting from current world.

Definition at line 1043 of file Player.cpp.

◆ IsGameModeCreative()

bool cPlayer::IsGameModeCreative ( void  ) const

Returns true if the player is in Creative mode, either explicitly, or by inheriting from current world.

Definition at line 1025 of file Player.cpp.

◆ IsGameModeSpectator()

bool cPlayer::IsGameModeSpectator ( void  ) const

Returns true if the player is in Spectator mode, either explicitly, or by inheriting from current world.

Definition at line 1052 of file Player.cpp.

◆ IsGameModeSurvival()

bool cPlayer::IsGameModeSurvival ( void  ) const

Returns true if the player is in Survival mode, either explicitly, or by inheriting from current world.

Definition at line 1034 of file Player.cpp.

◆ IsInBed()

bool cPlayer::IsInBed ( void  ) const

Returns true if a player is sleeping in a bed.

Definition at line 451 of file Player.cpp.

◆ IsInsideWater()

bool cPlayer::IsInsideWater ( )
private

Checks if the player is inside of water.

Definition at line 2578 of file Player.cpp.

◆ IsInvisible()

bool cPlayer::IsInvisible ( ) const
overrideprivatevirtual

Reimplemented from cPawn.

Definition at line 2976 of file Player.cpp.

◆ IsLeftHanded()

bool cPlayer::IsLeftHanded ( ) const

Returns true if the player's left hand is dominant.

Definition at line 460 of file Player.cpp.

◆ IsOnGround()

virtual bool cPlayer::IsOnGround ( void  ) const
inlineoverridevirtual

Returns whether the entity is on ground or not.

Reimplemented from cEntity.

Definition at line 604 of file Player.h.

◆ IsRclking()

virtual bool cPlayer::IsRclking ( void  ) const
inlineoverrideprivatevirtual

Reimplemented from cEntity.

Definition at line 803 of file Player.h.

◆ IsRespawnPointForced()

bool cPlayer::IsRespawnPointForced ( void  ) const
inline

Returns if the respawn point is unconditionally used.

Definition at line 518 of file Player.h.

◆ IsSatiated()

bool cPlayer::IsSatiated ( void  ) const
inline

Returns true if the player is satiated, i.

e. their foodlevel is at the max and they cannot eat anymore

Definition at line 360 of file Player.h.

◆ IsSprinting()

bool cPlayer::IsSprinting ( void  ) const
overridevirtual

Reimplemented from cEntity.

Definition at line 2958 of file Player.cpp.

◆ IsStanding()

bool cPlayer::IsStanding ( ) const

Returns true if a player is standing normally, that is, in a neutral pose.

Definition at line 469 of file Player.cpp.

◆ Killed()

void cPlayer::Killed ( const cEntity a_Victim,
eDamageType  a_DamageType 
)
overridevirtual

Called when the entity kills another entity.

Reimplemented from cEntity.

Definition at line 896 of file Player.cpp.

◆ KilledBy()

void cPlayer::KilledBy ( TakeDamageInfo a_TDI)
overridevirtual

Called when the health drops below zero.

a_TDI's Attacker may be nullptr (environmental damage)

Reimplemented from cPawn.

Definition at line 855 of file Player.cpp.

◆ LoadFromDisk()

void cPlayer::LoadFromDisk ( )

Loads the player data from the save file.

Sets m_World to the world where the player will spawn, based on the stored world name or the default world by calling LoadFromFile().

Definition at line 1803 of file Player.cpp.

◆ LoadRank()

void cPlayer::LoadRank ( void  )

(Re)loads the rank and permissions from the cRankManager and sends a permission level update to the client.

Definition at line 2312 of file Player.cpp.

◆ NotifyNearbyWolves()

void cPlayer::NotifyNearbyWolves ( cPawn a_Opponent,
bool  a_IsPlayerInvolved 
)

Notify nearby wolves that the player or one of the player's wolves took damage or did damage to an entity.

Parameters
a_Opponentthe opponent we're fighting.
a_IsPlayerInvolvedShould be true if the player took or did damage, and false if one of the player's wolves took or did damage.

Definition at line 831 of file Player.cpp.

◆ OnAddToWorld()

void cPlayer::OnAddToWorld ( cWorld a_World)
overrideprivatevirtual

Called when the entity is added to a world.

e.g after first spawning or after successfuly moving between worlds.

Parameters
a_WorldThe world being added to.

Reimplemented from cEntity.

Definition at line 2985 of file Player.cpp.

◆ OnDetach()

void cPlayer::OnDetach ( )
overrideprivatevirtual

Called when this entity dismounts from m_AttachedTo.

Reimplemented from cEntity.

Definition at line 3036 of file Player.cpp.

◆ OnLoseSpectated()

void cPlayer::OnLoseSpectated ( )

Called when spectation stops, because the player crouched or when the entity we're spectating gets removed from the world.

Definition at line 173 of file Player.cpp.

◆ OnRemoveFromWorld()

void cPlayer::OnRemoveFromWorld ( cWorld a_World)
overrideprivatevirtual

Called when the entity is removed from a world.

e.g. When the entity is destroyed or moved to a different world.

Parameters
a_WorldThe world being removed from.

Reimplemented from cPawn.

Definition at line 3075 of file Player.cpp.

◆ OpenHorseInventory()

void cPlayer::OpenHorseInventory ( )

Opens the inventory of any tame horse the player is riding.

If the player is not riding a horse or if the horse is untamed, does nothing.

Definition at line 1904 of file Player.cpp.

◆ OpenWindow()

void cPlayer::OpenWindow ( cWindow a_Window)

Opens the specified window; closes the current one first using CloseWindow()

Definition at line 1123 of file Player.cpp.

◆ PermissionMatches()

bool cPlayer::PermissionMatches ( const AStringVector a_Permission,
const AStringVector a_Template 
)
static

Returns true iff a_Permission matches the a_Template.

A match is defined by either being exactly the same, or each sub-item matches until there's a wildcard in a_Template. Ie. {"a", "b", "c"} matches {"a", "b", "*"} but doesn't match {"a", "b"}

Definition at line 1622 of file Player.cpp.

◆ PermuteEnchantmentSeed()

void cPlayer::PermuteEnchantmentSeed ( )

Permute the seed for enchanting related PRNGs, don't use this for other purposes.

Definition at line 1576 of file Player.cpp.

◆ PlaceBlock()

bool cPlayer::PlaceBlock ( Vector3i  a_Position,
BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta 
)

Attempts to place the block in the world with a call to PlaceBlocks.

Definition at line 2440 of file Player.cpp.

◆ PlaceBlocks()

bool cPlayer::PlaceBlocks ( std::initializer_list< sSetBlock a_Blocks)

Calls the block placement hooks and places the blocks in the world.

First the "placing" hooks for all the blocks are called, then the blocks are placed, and finally the "placed" hooks are called. If the any of the "placing" hooks aborts, none of the blocks are placed and the function returns false. Returns true if all the blocks are placed.

Definition at line 2449 of file Player.cpp.

◆ RefreshRank()

void cPlayer::RefreshRank ( )
private

(Re)loads the rank and permissions from the cRankManager.

Loads the m_Rank, m_Permissions, m_MsgPrefix, m_MsgSuffix and m_MsgNameColorCode members.

Definition at line 2807 of file Player.cpp.

◆ ReplaceOneEquippedItemTossRest()

void cPlayer::ReplaceOneEquippedItemTossRest ( const cItem a_Item)

Removes one item from the the current equipped item stack, and attempts to add the specified item stack back to the same slot.

If it is not possible to place the item in the same slot, tries to place the specified item elsewhere in the inventory. If this is not possible, then any remaining items are tossed. If the currently equipped slot is empty, its contents are simply set to the given Item.

Definition at line 1745 of file Player.cpp.

◆ Respawn()

void cPlayer::Respawn ( void  )

Definition at line 936 of file Player.cpp.

◆ SaveToDisk()

void cPlayer::SaveToDisk ( void  )

Saves all player data, such as inventory, to JSON.

Definition at line 1933 of file Player.cpp.

◆ SendAboveActionBarMessage() [1/2]

void cPlayer::SendAboveActionBarMessage ( const AString a_Message)

Definition at line 1272 of file Player.cpp.

◆ SendAboveActionBarMessage() [2/2]

void cPlayer::SendAboveActionBarMessage ( const cCompositeChat a_Message)

Definition at line 1290 of file Player.cpp.

◆ SendBlocksAround()

void cPlayer::SendBlocksAround ( Vector3i  a_BlockPos,
int  a_Range = 1 
)

Sends the block in the specified range around the specified coord to the client as a block change packet.

The blocks in range (a_BlockX - a_Range, a_BlockX + a_Range) are sent (NY-metric).

Definition at line 2325 of file Player.cpp.

◆ SendMessage() [1/2]

void cPlayer::SendMessage ( const AString a_Message)

Definition at line 1182 of file Player.cpp.

◆ SendMessage() [2/2]

void cPlayer::SendMessage ( const cCompositeChat a_Message)

Definition at line 1245 of file Player.cpp.

◆ SendMessageFailure()

void cPlayer::SendMessageFailure ( const AString a_Message)

Definition at line 1200 of file Player.cpp.

◆ SendMessageFatal()

void cPlayer::SendMessageFatal ( const AString a_Message)

Definition at line 1227 of file Player.cpp.

◆ SendMessageInfo()

void cPlayer::SendMessageInfo ( const AString a_Message)

Definition at line 1191 of file Player.cpp.

◆ SendMessagePrivateMsg()

void cPlayer::SendMessagePrivateMsg ( const AString a_Message,
const AString a_Sender 
)

Definition at line 1236 of file Player.cpp.

◆ SendMessageRaw()

void cPlayer::SendMessageRaw ( const AString a_MessageRaw,
eChatType  a_Type = eChatType::ctChatBox 
)

Definition at line 1254 of file Player.cpp.

◆ SendMessageSuccess()

void cPlayer::SendMessageSuccess ( const AString a_Message)

Definition at line 1209 of file Player.cpp.

◆ SendMessageWarning()

void cPlayer::SendMessageWarning ( const AString a_Message)

Definition at line 1218 of file Player.cpp.

◆ SendRotation()

void cPlayer::SendRotation ( double  a_YawDegrees,
double  a_PitchDegrees 
)

Sends the "look" packet to the player, forcing them to set their rotation to the specified values.

a_YawDegrees is clipped to range [-180, +180), a_PitchDegrees is clipped to range [-180, +180) but the client only uses [-90, +90]

Definition at line 1460 of file Player.cpp.

◆ SendSystemMessage() [1/2]

void cPlayer::SendSystemMessage ( const AString a_Message)

Definition at line 1263 of file Player.cpp.

◆ SendSystemMessage() [2/2]

void cPlayer::SendSystemMessage ( const cCompositeChat a_Message)

Definition at line 1281 of file Player.cpp.

◆ SetBedPos() [1/2]

void cPlayer::SetBedPos ( Vector3i  a_Position)

Sets the player's bed position to the specified position.

Sets the respawn world to the player's world and unforces the respawn point. The given position will be used subject to bed checks when respawning.

Definition at line 786 of file Player.cpp.

◆ SetBedPos() [2/2]

void cPlayer::SetBedPos ( Vector3i  a_Position,
const cWorld a_World 
)

Sets the player's bed position to the specified position.

The spawn point is unforced. The given position will be used subject to bed checks when respawning.

Definition at line 795 of file Player.cpp.

◆ SetCanFly()

void cPlayer::SetCanFly ( bool  a_CanFly)

If true the player can fly even when he's not in creative.

Definition at line 748 of file Player.cpp.

◆ SetCrouch()

void cPlayer::SetCrouch ( bool  a_ShouldCrouch)

Starts or stops crouching, if our current body stance permits, broadcasting the state change.

Definition at line 656 of file Player.cpp.

◆ SetCurrentExperience()

bool cPlayer::SetCurrentExperience ( int  a_XpTotal)

Sets the experience total Returns true on success "should" really only be called at init or player death, plugins excepted.

Definition at line 259 of file Player.cpp.

◆ SetCustomName()

void cPlayer::SetCustomName ( const AString a_CustomName)

Sets the custom name of this player.

If you want to disable the custom name, simply set an empty string. The custom name will be used in the tab-list, in the player nametag and in the tab-completion.

Definition at line 763 of file Player.cpp.

◆ SetDraggingItem()

void cPlayer::SetDraggingItem ( const cItem a_Item)

In UI windows, set the item that the player is dragging.

Definition at line 1707 of file Player.cpp.

◆ SetElytraFlight()

void cPlayer::SetElytraFlight ( bool  a_ShouldElytraFly)

Starts or stops elytra flight, if our current body stance permits, broadcasting the state change.

Definition at line 682 of file Player.cpp.

◆ SetFlying()

void cPlayer::SetFlying ( bool  a_ShouldFly)

Starts or stops flying, broadcasting the state change.

Definition at line 700 of file Player.cpp.

◆ SetFlyingMaxSpeed()

void cPlayer::SetFlyingMaxSpeed ( double  a_Speed)

Sets the flying relative maximum speed.

Sends the update to player, if needed.

Definition at line 641 of file Player.cpp.

◆ SetFoodExhaustionLevel()

void cPlayer::SetFoodExhaustionLevel ( double  a_FoodExhaustionLevel)

Definition at line 414 of file Player.cpp.

◆ SetFoodLevel()

void cPlayer::SetFoodLevel ( int  a_FoodLevel)

Definition at line 379 of file Player.cpp.

◆ SetFoodSaturationLevel()

void cPlayer::SetFoodSaturationLevel ( double  a_FoodSaturationLevel)

Definition at line 396 of file Player.cpp.

◆ SetFoodTickTimer()

void cPlayer::SetFoodTickTimer ( int  a_FoodTickTimer)

Definition at line 405 of file Player.cpp.

◆ SetGameMode()

void cPlayer::SetGameMode ( eGameMode  a_GameMode)

Sets the gamemode for the player.

The gamemode may be gmNotSet, in that case the player inherits the world's gamemode. Updates the gamemode on the client (sends the packet)

Definition at line 1308 of file Player.cpp.

◆ SetIsFishing()

void cPlayer::SetIsFishing ( bool  a_IsFishing,
UInt32  a_FloaterID = cEntity::INVALID_ID 
)
inline

Definition at line 388 of file Player.h.

◆ SetIsInBed()

void cPlayer::SetIsInBed ( bool  a_IsInBed)

Sets a player's in-bed state.

We can't be sure plugins will keep this value updated, so no exporting. If value is false (not in bed), will update players of the fact that they have been ejected from the bed.

Definition at line 496 of file Player.cpp.

◆ SetLeftHanded()

void cPlayer::SetLeftHanded ( bool  a_IsLeftHanded)

Sets the dominant hand of the player.

Definition at line 719 of file Player.cpp.

◆ SetNormalMaxSpeed()

void cPlayer::SetNormalMaxSpeed ( double  a_Speed)

Sets the normal relative maximum speed.

Sends the update to player, if needed.

Definition at line 611 of file Player.cpp.

◆ SetRespawnPosition()

void cPlayer::SetRespawnPosition ( Vector3i  a_Position,
const cWorld a_World 
)

Sets the player's forced respawn position and world.

Definition at line 806 of file Player.cpp.

◆ SetSkinParts()

void cPlayer::SetSkinParts ( int  a_Parts)

Definition at line 2504 of file Player.cpp.

◆ SetSprint()

void cPlayer::SetSprint ( bool  a_ShouldSprint)

Starts or stops sprinting, if our current body stance permits, broadcasting the state change.

Definition at line 729 of file Player.cpp.

◆ SetSprintingMaxSpeed()

void cPlayer::SetSprintingMaxSpeed ( double  a_Speed)

Sets the sprinting relative maximum speed.

Sends the update to player, if needed.

Definition at line 626 of file Player.cpp.

◆ SetTeam()

void cPlayer::SetTeam ( cTeam a_Team)

Sets the player team, nullptr if none.

Definition at line 1079 of file Player.cpp.

◆ SetTouchGround()

void cPlayer::SetTouchGround ( bool  a_bTouchGround)

Definition at line 351 of file Player.cpp.

◆ SetVisible()

void cPlayer::SetVisible ( bool  a_bVisible)

Definition at line 1549 of file Player.cpp.

◆ SpawnOn()

void cPlayer::SpawnOn ( cClientHandle a_Client)
overrideprivatevirtual

Descendants override this function to send a command to the specified client to spawn the entity on the client.

To spawn on all eligible clients, use cChunkMap::BroadcastSpawnEntity()

Implements cEntity.

Definition at line 3137 of file Player.cpp.

◆ SpectateEntity()

void cPlayer::SpectateEntity ( cEntity a_Target)

Spectates the target entity.

If a_Target is nullptr or a pointer to self, end spectation.

Definition at line 1471 of file Player.cpp.

◆ StartChargingBow()

void cPlayer::StartChargingBow ( void  )

Starts charging the equipped bow.

Definition at line 312 of file Player.cpp.

◆ StartEating()

void cPlayer::StartEating ( void  )

Starts eating the currently equipped item.

Resets the eating timer and sends the proper animation packet

Definition at line 514 of file Player.cpp.

◆ TeleportToCoords()

void cPlayer::TeleportToCoords ( double  a_PosX,
double  a_PosY,
double  a_PosZ 
)
overridevirtual

Teleports to the coordinates specified.

Reimplemented from cEntity.

Definition at line 1404 of file Player.cpp.

◆ Tick()

void cPlayer::Tick ( std::chrono::milliseconds  a_Dt,
cChunk a_Chunk 
)
overrideprivatevirtual

Reimplemented from cPawn.

Definition at line 3157 of file Player.cpp.

◆ TickFreezeCode()

void cPlayer::TickFreezeCode ( )
private

Definition at line 2749 of file Player.cpp.

◆ TossEquippedItem()

void cPlayer::TossEquippedItem ( char  a_Amount = 1)

tosses the item in the selected hotbar slot

Definition at line 1720 of file Player.cpp.

◆ TossHeldItem()

void cPlayer::TossHeldItem ( char  a_Amount = 1)

tosses the item held in hand (when in UI windows)

Definition at line 1764 of file Player.cpp.

◆ TossItems()

void cPlayer::TossItems ( const cItems a_Items)

Tosses a list of items.

Definition at line 478 of file Player.cpp.

◆ TossPickup()

void cPlayer::TossPickup ( const cItem a_Item)

tosses a pickup newly created from a_Item

Definition at line 1791 of file Player.cpp.

◆ Unfreeze()

void cPlayer::Unfreeze ( )

Cancels Freeze(...) and allows the player to move naturally.

Definition at line 1441 of file Player.cpp.

◆ UpdateCapabilities()

void cPlayer::UpdateCapabilities ( )

Updates player's capabilities - flying, visibility, etc.

from their gamemode.

Definition at line 1346 of file Player.cpp.

◆ UpdateMovementStats()

void cPlayer::UpdateMovementStats ( const Vector3d a_DeltaPos,
bool  a_PreviousIsOnGround 
)

Update movement-related statistics.

Definition at line 2216 of file Player.cpp.

◆ UpdateTeam()

cTeam * cPlayer::UpdateTeam ( void  )

Forces the player to query the scoreboard for his team.

Definition at line 1103 of file Player.cpp.

◆ UseEquippedItem() [1/2]

void cPlayer::UseEquippedItem ( cItemHandler::eDurabilityLostAction  a_Action)

Damage the player's equipped item by the amount of damage such an item is damaged by when used for a_Action.

Definition at line 2048 of file Player.cpp.

◆ UseEquippedItem() [2/2]

void cPlayer::UseEquippedItem ( short  a_Damage = 1)

Damage the player's equipped item by a_Damage, possibly less if the equipped item is enchanted.

Definition at line 2033 of file Player.cpp.

◆ UseItem()

void cPlayer::UseItem ( int  a_SlotNumber,
short  a_Damage = 1 
)

Damage the item in a_SlotNumber by a_Damage, possibly less if the equipped item is enchanted.

Definition at line 2063 of file Player.cpp.

◆ XpForLevel()

int cPlayer::XpForLevel ( int  a_Level)
static

Calculates the amount of XP needed for a given level Ref: https://minecraft.gamepedia.com/XP.

Definition at line 215 of file Player.cpp.

Member Data Documentation

◆ m_BodyStance

The current body stance the player has adopted.

Definition at line 612 of file Player.h.

◆ m_BowCharge

int cPlayer::m_BowCharge
private

Definition at line 730 of file Player.h.

◆ m_ClientHandle

std::shared_ptr<cClientHandle> cPlayer::m_ClientHandle
private

Definition at line 677 of file Player.h.

◆ m_CurrentWindow

cWindow* cPlayer::m_CurrentWindow
private

Definition at line 654 of file Player.h.

◆ m_CurrentWorldName

std::string cPlayer::m_CurrentWorldName
private

The name of the world which the player currently resides in.

Stored in addition to m_World to allow SaveToDisk to be safely called in the player's destructor.

Definition at line 667 of file Player.h.

◆ m_CurrentXp

int cPlayer::m_CurrentXp
private

Definition at line 727 of file Player.h.

◆ m_CustomName

AString cPlayer::m_CustomName
private

Definition at line 745 of file Player.h.

◆ m_DefaultWorldPath

std::string cPlayer::m_DefaultWorldPath
private

The save path of the default world.

Definition at line 670 of file Player.h.

◆ m_DraggingItem

cItem cPlayer::m_DraggingItem
private

The item being dragged by the cursor while in a UI window.

Definition at line 675 of file Player.h.

◆ m_EatingFinishTick

cTickTimeLong cPlayer::m_EatingFinishTick
private

The world tick in which eating will be finished.

-1 if not eating

Definition at line 723 of file Player.h.

◆ m_EnchantmentSeed

unsigned int cPlayer::m_EnchantmentSeed
private

Definition at line 728 of file Player.h.

◆ m_EnderChestContents

cItemGrid cPlayer::m_EnderChestContents
private

An item grid that stores the player specific enderchest contents.

Definition at line 652 of file Player.h.

◆ m_FloaterID

UInt32 cPlayer::m_FloaterID
private

Definition at line 732 of file Player.h.

◆ m_FlyingMaxSpeed

double cPlayer::m_FlyingMaxSpeed
private

Max speed, relative to the game default flying max speed, when flying.

1 means regular speed, 2 means twice as fast, 0.5 means half-speed. Default value is 1.

Definition at line 694 of file Player.h.

◆ m_FoodExhaustionLevel

double cPlayer::m_FoodExhaustionLevel
private

A "buffer" which adds up hunger before it is substracted from m_FoodSaturationLevel or m_FoodLevel.

Each action adds a little

Definition at line 646 of file Player.h.

◆ m_FoodLevel

int cPlayer::m_FoodLevel
private

Represents the food bar, one point equals half a "drumstick".

Definition at line 637 of file Player.h.

◆ m_FoodSaturationLevel

double cPlayer::m_FoodSaturationLevel
private

"Overcharge" for the m_FoodLevel; is depleted before m_FoodLevel

Definition at line 640 of file Player.h.

◆ m_FoodTickTimer

int cPlayer::m_FoodTickTimer
private

Count-up to the healing or damaging action, based on m_FoodLevel.

Definition at line 643 of file Player.h.

◆ m_GameMode

eGameMode cPlayer::m_GameMode
private

Definition at line 672 of file Player.h.

◆ m_Inventory

cInventory cPlayer::m_Inventory
private

Stores the player's inventory, consisting of crafting grid, hotbar, and main slots.

Definition at line 649 of file Player.h.

◆ m_InventoryPaintSlots

cSlotNums cPlayer::m_InventoryPaintSlots
private

Definition at line 679 of file Player.h.

◆ m_InventoryWindow

cWindow* cPlayer::m_InventoryWindow
private

Definition at line 655 of file Player.h.

◆ m_IsChargingBow

bool cPlayer::m_IsChargingBow
private

Definition at line 696 of file Player.h.

◆ m_IsFishing

bool cPlayer::m_IsFishing
private

Definition at line 697 of file Player.h.

◆ m_IsFlightCapable

bool cPlayer::m_IsFlightCapable
private

If this is true the player can fly.

Even if he is not in creative.

Definition at line 700 of file Player.h.

◆ m_IsFlying

bool cPlayer::m_IsFlying
private

Definition at line 702 of file Player.h.

◆ m_IsFrozen

bool cPlayer::m_IsFrozen
private

If true, we are locking m_Position to m_FrozenPosition.

Definition at line 705 of file Player.h.

◆ m_IsLeftHanded

bool cPlayer::m_IsLeftHanded
private

Whether the player is left-handed, or right-handed.

Definition at line 708 of file Player.h.

◆ m_IsManuallyFrozen

bool cPlayer::m_IsManuallyFrozen
private

Was the player frozen manually by a plugin or automatically by the server?

Definition at line 711 of file Player.h.

◆ m_IsRespawnPointForced

bool cPlayer::m_IsRespawnPointForced
private

Whether we unconditionally respawn to m_RespawnPosition, or check if a bed is unobstructed and available first.

Definition at line 714 of file Player.h.

◆ m_IsTeleporting

bool cPlayer::m_IsTeleporting
private

Flag used by food handling system to determine whether a teleport has just happened.

Will not apply food penalties if found to be true; will set to false after processing.

Definition at line 718 of file Player.h.

◆ m_IsVisible

bool cPlayer::m_IsVisible
private

Definition at line 720 of file Player.h.

◆ m_KnownItems

std::set<cItem, cItem::sItemCompare> cPlayer::m_KnownItems
private

List of known items as Ids.

Definition at line 754 of file Player.h.

◆ m_KnownRecipes

std::set<UInt32> cPlayer::m_KnownRecipes
private

List on known recipes as Ids.

Definition at line 751 of file Player.h.

◆ m_LifetimeTotalXp

int cPlayer::m_LifetimeTotalXp
private

Player Xp level.

Definition at line 726 of file Player.h.

◆ m_MsgNameColorCode

AString cPlayer::m_MsgNameColorCode
private

Definition at line 633 of file Player.h.

◆ m_MsgPrefix

AString cPlayer::m_MsgPrefix
private

Definition at line 632 of file Player.h.

◆ m_MsgSuffix

AString cPlayer::m_MsgSuffix
private

Definition at line 632 of file Player.h.

◆ m_NormalMaxSpeed

double cPlayer::m_NormalMaxSpeed
private

Max speed, relative to the game default.

1 means regular speed, 2 means twice as fast, 0.5 means half-speed. Default value is 1.

Definition at line 684 of file Player.h.

◆ m_Permissions

AStringVector cPlayer::m_Permissions
private

All the permissions that this player has, based on their rank.

Definition at line 618 of file Player.h.

◆ m_Rank

AString cPlayer::m_Rank
private

The name of the rank assigned to this player.

Definition at line 615 of file Player.h.

◆ m_RespawnPosition

Vector3i cPlayer::m_RespawnPosition
private

The player's potential respawn position, initialised to world spawn by default.

During player respawn from death, if m_IsRespawnPointForced is false and no bed exists here, it will be reset to world spawn.

Definition at line 659 of file Player.h.

◆ m_Restrictions

AStringVector cPlayer::m_Restrictions
private

All the restrictions that this player has, based on their rank.

Definition at line 621 of file Player.h.

◆ m_SkinParts

int cPlayer::m_SkinParts
private

Displayed skin part bit mask.

Definition at line 748 of file Player.h.

◆ m_SpawnWorldName

std::string cPlayer::m_SpawnWorldName
private

The name of the world which the player respawns in upon death.

This is stored as a string to enable SaveToDisk to not touch cRoot, and thus can be safely called in the player's destructor.

Definition at line 663 of file Player.h.

◆ m_Spectating

cEntity* cPlayer::m_Spectating
private

The entity that this player is spectating, nullptr if none.

Definition at line 737 of file Player.h.

◆ m_SplitPermissions

AStringVectorVector cPlayer::m_SplitPermissions
private

All the permissions that this player has, based on their rank, split into individual dot-delimited parts.

This is used mainly by the HasPermission() function to optimize the lookup.

Definition at line 625 of file Player.h.

◆ m_SplitRestrictions

AStringVectorVector cPlayer::m_SplitRestrictions
private

All the restrictions that this player has, based on their rank, split into individual dot-delimited parts.

This is used mainly by the HasPermission() function to optimize the lookup.

Definition at line 629 of file Player.h.

◆ m_SprintingMaxSpeed

double cPlayer::m_SprintingMaxSpeed
private

Max speed, relative to the game default max speed, when sprinting.

1 means regular speed, 2 means twice as fast, 0.5 means half-speed. Default value is 1.3.

Definition at line 689 of file Player.h.

◆ m_Stats

StatisticsManager cPlayer::m_Stats
private

Definition at line 739 of file Player.h.

◆ m_Team

cTeam* cPlayer::m_Team
private

Definition at line 734 of file Player.h.

◆ m_TicksUntilNextSave

unsigned int cPlayer::m_TicksUntilNextSave
private

How long till the player's inventory will be saved Default save interval is #defined in PLAYER_INVENTORY_SAVE_INTERVAL.

Definition at line 743 of file Player.h.

◆ MAX_FOOD_LEVEL

const int cPlayer::MAX_FOOD_LEVEL = 20
static

Definition at line 87 of file Player.h.

◆ MAX_HEALTH

const int cPlayer::MAX_HEALTH = 20
static

Definition at line 85 of file Player.h.


The documentation for this class was generated from the following files: