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

#include <Entity.h>

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

Classes

struct  sPortalCooldownData
 Structure storing the portal delay timer and cooldown boolean. More...
 
struct  sWorldChangeInfo
 State variables for MoveToWorld. More...
 

Public Types

enum  eEntityType {
  etEntity , etEnderCrystal , etPlayer , etPickup ,
  etMonster , etFallingBlock , etMinecart , etBoat ,
  etTNT , etProjectile , etExpOrb , etFloater ,
  etItemFrame , etPainting , etLeashKnot , etMob = etMonster
}
 

Public Member Functions

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 void ApplyArmorDamage (int DamageBlocked)
 Applies damage to the armor after the armor blocked the given amount. More...
 
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...
 
virtual void BroadcastMovementUpdate (const cClientHandle *a_Exclude=nullptr)
 Updates clients of changes in 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...
 
virtual bool DoTakeDamage (TakeDamageInfo &a_TDI)
 Makes this entity take damage specified in the a_TDI. 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 GetEnchantmentBlastKnockbackReduction ()
 Returns explosion knock back reduction percent from blast protection level. 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
 
virtual cItem GetEquippedBoots (void) const
 Returns the currently equipped boots; empty item if none. More...
 
virtual cItem GetEquippedChestplate (void) const
 Returns the currently equipped chestplate; empty item if none. More...
 
virtual cItem GetEquippedHelmet (void) const
 Returns the currently equipped helmet; empty item if none. More...
 
virtual cItem GetEquippedLeggings (void) const
 Returns the currently equipped leggings; empty item if none. More...
 
virtual cItem GetEquippedWeapon (void) const
 Returns the curently equipped weapon; empty item if none. More...
 
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
 
virtual cItem GetOffHandEquipedItem (void) const
 Returns the currently offhand equipped item; empty item if none. More...
 
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 HandlePhysics (std::chrono::milliseconds a_Dt, cChunk &a_Chunk)
 Handles the physics of the entity - updates position based on speed, updates speed based on environment. More...
 
virtual void HandleSpeedFromAttachee (float a_Forward, float a_Sideways)
 
bool HasAnyMobLeashed () const
 Returs whether the entity has any mob leashed to it. More...
 
virtual void Heal (int a_HitPoints)
 Heals the specified amount of HPs. 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
 
virtual bool IsCrouched (void) const
 
bool IsDestroyed () const
 Deprecated. More...
 
virtual bool IsElytraFlying (void) const
 
bool IsEnderCrystal (void) const
 
bool IsExpOrb (void) const
 
bool IsFallingBlock (void) const
 
virtual bool IsFireproof (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 IsInvisible (void) const
 
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
 
virtual bool IsOnGround (void) const
 Returns whether the entity is on ground or not. More...
 
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 IsRclking (void) const
 
virtual bool IsRiding (void) const
 
virtual bool IsSprinting (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...
 
virtual void Killed (const cEntity &a_Victim, eDamageType a_DamageType)
 Called when the entity kills another entity. More...
 
virtual void KilledBy (TakeDamageInfo &a_TDI)
 Called when the health drops below zero. 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 OnAddToWorld (cWorld &a_World)
 Called when the entity is added to a world. 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 OnRemoveFromWorld (cWorld &a_World)
 Called when the entity is removed from a world. 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...
 
virtual void SpawnOn (cClientHandle &a_Client)=0
 Descendants override this function to send a command to the specified client to spawn the entity on the client. 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 TeleportToCoords (double a_PosX, double a_PosY, double a_PosZ)
 Teleports to the coordinates specified. More...
 
virtual void TeleportToEntity (cEntity &a_Entity)
 Teleports to the entity specified. More...
 
virtual void Tick (std::chrono::milliseconds a_Dt, cChunk &a_Chunk)
 
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 const char * GetClassStatic (void)
 Returns the class name of this class. More...
 

Static Public Attributes

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...
 

Protected Member Functions

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 HandleAir (void)
 Called in each tick to handle air-related processing i.e. More...
 
virtual void OnDetach ()
 Called when this entity dismounts from m_AttachedTo. More...
 
virtual void ResetPosition (Vector3d a_NewPos)
 Set the entities position and last sent position. 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

static void ApplyFriction (Vector3d &a_Speed, double a_SlowdownMultiplier, float a_Dt)
 Applies friction to an entity. More...
 

Protected Attributes

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.wiki/w/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...
 

Private Types

typedef std::list< cMonster * > cMonsterList
 

Private Attributes

double m_HeadYaw
 Measured in degrees, [-180, +180) More...
 
float m_Height
 Height of the entity (Y axis). More...
 
int m_InvulnerableTicks
 If a player hit a entity, the entity receive a invulnerable of 10 ticks. More...
 
bool m_IsTicking
 Whether the entity is ticking or not. More...
 
cMonsterList m_LeashedMobs
 List of leashed mobs to this entity. More...
 
double m_Mass
 Measured in Kilograms (Kg) More...
 
cChunkm_ParentChunk
 The chunk which is responsible for ticking this entity. More...
 
Vector3d m_Position
 Position of the entity's XZ center and Y bottom. More...
 
Vector3d m_Rot
 Measured in degrees, [-180, +180) More...
 
std::vector< cPlayer * > m_Spectators
 List of players who are spectating this entity. More...
 
Vector3d m_WaterSpeed
 Measured in meter / second. More...
 
float m_Width
 Width of the entity, in the XZ plane. More...
 

Detailed Description

Definition at line 75 of file Entity.h.

Member Typedef Documentation

◆ cMonsterList

typedef std::list<cMonster *> cEntity::cMonsterList
private

Definition at line 728 of file Entity.h.

Member Enumeration Documentation

◆ eEntityType

Enumerator
etEntity 
etEnderCrystal 
etPlayer 
etPickup 
etMonster 
etFallingBlock 
etMinecart 
etBoat 
etTNT 
etProjectile 
etExpOrb 
etFloater 
etItemFrame 
etPainting 
etLeashKnot 
etMob 

Definition at line 88 of file Entity.h.

Constructor & Destructor Documentation

◆ cEntity()

cEntity::cEntity ( eEntityType  a_EntityType,
Vector3d  a_Pos,
float  a_Width,
float  a_Height 
)

Definition at line 37 of file Entity.cpp.

◆ ~cEntity()

virtual cEntity::~cEntity ( )
virtualdefault

Member Function Documentation

◆ AddLeashedMob()

void cEntity::AddLeashedMob ( cMonster a_Monster)

Adds a mob to the leashed list of mobs.

Definition at line 2299 of file Entity.cpp.

◆ AddPosition() [1/2]

void cEntity::AddPosition ( const Vector3d a_AddPos)
inline

Definition at line 243 of file Entity.h.

◆ AddPosition() [2/2]

void cEntity::AddPosition ( double  a_AddPosX,
double  a_AddPosY,
double  a_AddPosZ 
)
inline

Definition at line 242 of file Entity.h.

◆ AddPosX()

void cEntity::AddPosX ( double  a_AddPosX)
inline

Definition at line 239 of file Entity.h.

◆ AddPosY()

void cEntity::AddPosY ( double  a_AddPosY)
inline

Definition at line 240 of file Entity.h.

◆ AddPosZ()

void cEntity::AddPosZ ( double  a_AddPosZ)
inline

Definition at line 241 of file Entity.h.

◆ AddSpeed() [1/2]

void cEntity::AddSpeed ( const Vector3d a_AddSpeed)
inline

Definition at line 245 of file Entity.h.

◆ AddSpeed() [2/2]

void cEntity::AddSpeed ( double  a_AddSpeedX,
double  a_AddSpeedY,
double  a_AddSpeedZ 
)

Definition at line 2194 of file Entity.cpp.

◆ AddSpeedX()

void cEntity::AddSpeedX ( double  a_AddSpeedX)

Definition at line 2203 of file Entity.cpp.

◆ AddSpeedY()

void cEntity::AddSpeedY ( double  a_AddSpeedY)

Definition at line 2212 of file Entity.cpp.

◆ AddSpeedZ()

void cEntity::AddSpeedZ ( double  a_AddSpeedZ)

Definition at line 2221 of file Entity.cpp.

◆ ApplyArmorDamage()

void cEntity::ApplyArmorDamage ( int  DamageBlocked)
virtual

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

Reimplemented in cPlayer.

Definition at line 652 of file Entity.cpp.

◆ ApplyFriction()

void cEntity::ApplyFriction ( Vector3d a_Speed,
double  a_SlowdownMultiplier,
float  a_Dt 
)
staticprotected

Applies friction to an entity.

Parameters
a_SpeedThe speed vector to apply changes to
a_SlowdownMultiplierThe factor to reduce the speed by

Definition at line 1230 of file Entity.cpp.

◆ ArmorCoversAgainst()

bool cEntity::ArmorCoversAgainst ( eDamageType  a_DamageType)
virtual

Returns whether armor will protect against the specified damage type.

Definition at line 661 of file Entity.cpp.

◆ AttachTo()

void cEntity::AttachTo ( cEntity a_AttachTo)

Attaches to the specified entity; detaches from any previous one first.

Definition at line 2027 of file Entity.cpp.

◆ BroadcastDeathMessage()

void cEntity::BroadcastDeathMessage ( TakeDamageInfo a_TDI)

Announces a death message on chat about killing the entity.

Definition at line 2349 of file Entity.cpp.

◆ BroadcastLeashedMobs()

void cEntity::BroadcastLeashedMobs ( )
protected

If has any mobs are leashed, broadcasts every leashed entity to this.

Definition at line 2325 of file Entity.cpp.

◆ BroadcastMovementUpdate()

void cEntity::BroadcastMovementUpdate ( const cClientHandle a_Exclude = nullptr)
virtual

Updates clients of changes in the entity.

Reimplemented in cPlayer, and cBoat.

Definition at line 1966 of file Entity.cpp.

◆ Destroy()

void cEntity::Destroy ( void  )

Destroys the entity, schedules it for memory freeing and broadcasts the DestroyEntity packet.

Definition at line 243 of file Entity.cpp.

◆ Detach()

void cEntity::Detach ( void  )

Detaches from the currently attached entity, if any.

Definition at line 2052 of file Entity.cpp.

◆ DetectCacti()

void cEntity::DetectCacti ( void  )
virtual

Detects the time for application of cacti damage.

Definition at line 1363 of file Entity.cpp.

◆ DetectMagma()

void cEntity::DetectMagma ( void  )
virtual

Detects the time for application of magma block damage.

Definition at line 1392 of file Entity.cpp.

◆ DetectPortal()

bool cEntity::DetectPortal ( void  )
virtual

Detects whether we are in a portal block and begins teleportation procedures if so Returns true if MoveToWorld() was called, false if not.

Definition at line 1421 of file Entity.cpp.

◆ DoesPreventBlockPlacement()

virtual bool cEntity::DoesPreventBlockPlacement ( void  ) const
inlinevirtual

Returns whether blocks can be placed intersecting this entities' hitbox.

Reimplemented in cPickup, and cArrowEntity.

Definition at line 188 of file Entity.h.

◆ DoMoveToWorld()

void cEntity::DoMoveToWorld ( const sWorldChangeInfo a_WorldChangeInfo)
protected

Handles the moving of this entity between worlds.

Should handle degenerate cases such as moving to the same world.

Definition at line 1573 of file Entity.cpp.

◆ DoTakeDamage()

bool cEntity::DoTakeDamage ( TakeDamageInfo a_TDI)
virtual

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 in cPlayer, cMinecart, cBoat, cWolf, cWither, cVillager, cSpider, cSilverfish, cPig, cPassiveMonster, cPassiveAggressiveMonster, cOcelot, cMonster, cGhast, cEnderDragon, cCreeper, cChicken, cPickup, cItemFrame, and cExpOrb.

Definition at line 404 of file Entity.cpp.

◆ GetAirDrag()

float cEntity::GetAirDrag ( void  ) const
inline

Definition at line 284 of file Entity.h.

◆ GetAirLevel()

int cEntity::GetAirLevel ( void  ) const
inline

Gets remaining air of a monster.

Definition at line 507 of file Entity.h.

◆ GetArmorCoverAgainst()

float cEntity::GetArmorCoverAgainst ( const cEntity a_Attacker,
eDamageType  a_DamageType,
int  a_RawDamage 
)
virtual

Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover.

Definition at line 769 of file Entity.cpp.

◆ GetAttached()

cEntity * cEntity::GetAttached ( )

Gets entity (vehicle) attached to this entity.

Definition at line 2018 of file Entity.cpp.

◆ GetBoundingBox()

cBoundingBox cEntity::GetBoundingBox ( ) const
inline

Definition at line 211 of file Entity.h.

◆ GetChunkX()

int cEntity::GetChunkX ( void  ) const
inline

Definition at line 207 of file Entity.h.

◆ GetChunkZ()

int cEntity::GetChunkZ ( void  ) const
inline

Definition at line 208 of file Entity.h.

◆ GetClass()

const char * cEntity::GetClass ( void  ) const
virtual

Returns the topmost class name for the object.

Definition at line 84 of file Entity.cpp.

◆ GetClassStatic()

const char * cEntity::GetClassStatic ( void  )
static

Returns the class name of this class.

Definition at line 93 of file Entity.cpp.

◆ GetDrops()

virtual void cEntity::GetDrops ( cItems a_Drops,
cEntity a_Killer = nullptr 
)
inlinevirtual

Returns the list of drops for this pawn when it is killed.

May check a_Killer for special handling (sword of looting etc.). Called from KilledBy().

Reimplemented in cPainting, cLeashKnot, cItemFrame, cZombieVillager, cZombiePigman, cZombie, cWitherSkeleton, cWither, cWitch, cSquid, cSpider, cSnowGolem, cSlime, cSkeleton, cSheep, cRabbit, cPig, cMooshroom, cMagmaCube, cIronGolem, cHorse, cGuardian, cGiant, cGhast, cEnderman, cEnderDragon, cCreeper, cCow, cChicken, cCaveSpider, cBlaze, cMinecartWithHopper, cMinecartWithTNT, cMinecartWithFurnace, cMinecartWithChest, and cRideableMinecart.

Definition at line 527 of file Entity.h.

◆ GetEnchantmentBlastKnockbackReduction()

float cEntity::GetEnchantmentBlastKnockbackReduction ( )
virtual

Returns explosion knock back reduction percent from blast protection level.

Returns
knock back reduce percent

Reimplemented in cPlayer.

Definition at line 744 of file Entity.cpp.

◆ GetEnchantmentCoverAgainst()

float cEntity::GetEnchantmentCoverAgainst ( const cEntity a_Attacker,
eDamageType  a_DamageType,
int  a_Damage 
)
virtual

Returns the hitpoints that the currently equipped armor's enchantments would cover.

Definition at line 701 of file Entity.cpp.

◆ GetEntityType()

eEntityType cEntity::GetEntityType ( void  ) const
inline

Definition at line 156 of file Entity.h.

◆ GetEquippedBoots()

virtual cItem cEntity::GetEquippedBoots ( void  ) const
inlinevirtual

Returns the currently equipped boots; empty item if none.

Reimplemented in cPlayer.

Definition at line 345 of file Entity.h.

◆ GetEquippedChestplate()

virtual cItem cEntity::GetEquippedChestplate ( void  ) const
inlinevirtual

Returns the currently equipped chestplate; empty item if none.

Reimplemented in cPlayer.

Definition at line 339 of file Entity.h.

◆ GetEquippedHelmet()

virtual cItem cEntity::GetEquippedHelmet ( void  ) const
inlinevirtual

Returns the currently equipped helmet; empty item if none.

Reimplemented in cPlayer.

Definition at line 336 of file Entity.h.

◆ GetEquippedLeggings()

virtual cItem cEntity::GetEquippedLeggings ( void  ) const
inlinevirtual

Returns the currently equipped leggings; empty item if none.

Reimplemented in cPlayer.

Definition at line 342 of file Entity.h.

◆ GetEquippedWeapon()

virtual cItem cEntity::GetEquippedWeapon ( void  ) const
inlinevirtual

Returns the curently equipped weapon; empty item if none.

Reimplemented in cPlayer.

Definition at line 333 of file Entity.h.

◆ GetGravity()

float cEntity::GetGravity ( void  ) const
inline

Definition at line 280 of file Entity.h.

◆ GetHeadYaw()

double cEntity::GetHeadYaw ( void  ) const
inline

Definition at line 192 of file Entity.h.

◆ GetHealth()

float cEntity::GetHealth ( void  ) const
inline

Returns the health of this entity.

Definition at line 367 of file Entity.h.

◆ GetHeight()

float cEntity::GetHeight ( void  ) const
inline

Definition at line 193 of file Entity.h.

◆ GetInvulnerableTicks()

int cEntity::GetInvulnerableTicks ( void  ) const
inline

Gets the invulnerable ticks from the entity.

Definition at line 513 of file Entity.h.

◆ GetKnockbackAmountAgainst()

double cEntity::GetKnockbackAmountAgainst ( const cEntity a_Receiver)
virtual

Returns the knockback amount that the currently equipped items would cause to a_Receiver on a hit.

Definition at line 827 of file Entity.cpp.

◆ GetLastSentPosition()

Vector3d cEntity::GetLastSentPosition ( void  ) const
inline

Returns the last position we sent to all the clients.

Use this to initialize clients with our position.

Definition at line 304 of file Entity.h.

◆ GetLookVector()

Vector3d cEntity::GetLookVector ( void  ) const

Definition at line 2267 of file Entity.cpp.

◆ GetMass()

double cEntity::GetMass ( void  ) const
inline

Definition at line 194 of file Entity.h.

◆ GetMaxHealth()

float cEntity::GetMaxHealth ( void  ) const
inline

Definition at line 407 of file Entity.h.

◆ GetOffHandEquipedItem()

virtual cItem cEntity::GetOffHandEquipedItem ( void  ) const
inlinevirtual

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

Reimplemented in cPlayer.

Definition at line 348 of file Entity.h.

◆ GetParentChunk() [1/2]

cChunk* cEntity::GetParentChunk ( )
inline

Returns the chunk responsible for ticking this entity.

Definition at line 541 of file Entity.h.

◆ GetParentChunk() [2/2]

const cChunk* cEntity::GetParentChunk ( ) const
inline

Definition at line 542 of file Entity.h.

◆ GetParentClass()

const char * cEntity::GetParentClass ( void  ) const
virtual

Returns the topmost class's parent class name for the object.

cEntity returns an empty string (no parent).

Definition at line 102 of file Entity.cpp.

◆ GetPitch()

double cEntity::GetPitch ( void  ) const
inline

Definition at line 199 of file Entity.h.

◆ GetPosition()

const Vector3d& cEntity::GetPosition ( void  ) const
inline

Exported in ManualBindings.

Definition at line 297 of file Entity.h.

◆ GetPosX()

double cEntity::GetPosX ( void  ) const
inline

Definition at line 195 of file Entity.h.

◆ GetPosY()

double cEntity::GetPosY ( void  ) const
inline

Definition at line 196 of file Entity.h.

◆ GetPosZ()

double cEntity::GetPosZ ( void  ) const
inline

Definition at line 197 of file Entity.h.

◆ GetRawDamageAgainst()

int cEntity::GetRawDamageAgainst ( const cEntity a_Receiver)
virtual

Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items.

Definition at line 614 of file Entity.cpp.

◆ GetRoll()

double cEntity::GetRoll ( void  ) const
inline

Definition at line 200 of file Entity.h.

◆ GetSpeed()

const Vector3d& cEntity::GetSpeed ( void  ) const
inline

Exported in ManualBindings.

Definition at line 300 of file Entity.h.

◆ GetSpeedX()

double cEntity::GetSpeedX ( void  ) const
inline

Definition at line 202 of file Entity.h.

◆ GetSpeedY()

double cEntity::GetSpeedY ( void  ) const
inline

Definition at line 203 of file Entity.h.

◆ GetSpeedZ()

double cEntity::GetSpeedZ ( void  ) const
inline

Definition at line 204 of file Entity.h.

◆ GetTicksAlive()

long int cEntity::GetTicksAlive ( void  ) const
inline

Gets number of ticks this entity has been alive for.

Definition at line 510 of file Entity.h.

◆ GetUniqueID()

UInt32 cEntity::GetUniqueID ( void  ) const
inline

Definition at line 253 of file Entity.h.

◆ GetWidth()

float cEntity::GetWidth ( void  ) const
inline

Definition at line 205 of file Entity.h.

◆ GetWorld()

cWorld* cEntity::GetWorld ( void  ) const
inline

Definition at line 190 of file Entity.h.

◆ GetYaw()

double cEntity::GetYaw ( void  ) const
inline

Definition at line 198 of file Entity.h.

◆ HandleAir()

void cEntity::HandleAir ( void  )
protectedvirtual

Called in each tick to handle air-related processing i.e.

drowning

Reimplemented in cSquid, cIronGolem, cGuardian, and cPawn.

Definition at line 1798 of file Entity.cpp.

◆ HandlePhysics()

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

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

Reimplemented in cProjectileEntity, cMinecart, cFireworkEntity, cBoat, and cPlayer.

Definition at line 1001 of file Entity.cpp.

◆ HandleSpeedFromAttachee()

void cEntity::HandleSpeedFromAttachee ( float  a_Forward,
float  a_Sideways 
)
virtual

Reimplemented in cHorse, cMinecart, and cBoat.

Definition at line 2230 of file Entity.cpp.

◆ HasAnyMobLeashed()

bool cEntity::HasAnyMobLeashed ( ) const
inline

Returs whether the entity has any mob leashed to it.

Definition at line 557 of file Entity.h.

◆ Heal()

void cEntity::Heal ( int  a_HitPoints)
virtual

Heals the specified amount of HPs.

Reimplemented in cPlayer.

Definition at line 890 of file Entity.cpp.

◆ Initialize()

bool cEntity::Initialize ( OwnedEntity  a_Self,
cWorld a_EntityWorld 
)

Spawns the entity in the world; returns true if spawned, false if not (plugin disallowed).

Adds the entity to the world.

Definition at line 111 of file Entity.cpp.

◆ IsA()

bool cEntity::IsA ( const char *  a_ClassName) const
virtual

Returns true if the entity is of the specified class or a subclass (cPawn's IsA("cEntity") returns true)

Definition at line 2072 of file Entity.cpp.

◆ IsArrow()

bool cEntity::IsArrow ( void  ) const
inline

Definition at line 158 of file Entity.h.

◆ IsAttachedTo()

bool cEntity::IsAttachedTo ( const cEntity a_Entity) const

Returns true if this entity is attached to the specified entity.

Definition at line 2081 of file Entity.cpp.

◆ IsBoat()

bool cEntity::IsBoat ( void  ) const
inline

Definition at line 166 of file Entity.h.

◆ IsCrouched()

virtual bool cEntity::IsCrouched ( void  ) const
inlinevirtual

Reimplemented in cPlayer.

Definition at line 486 of file Entity.h.

◆ IsDestroyed()

bool cEntity::IsDestroyed ( void  ) const
inline

Deprecated.

Use IsTicking instead.

Definition at line 256 of file Entity.h.

◆ IsElytraFlying()

virtual bool cEntity::IsElytraFlying ( void  ) const
inlinevirtual

Reimplemented in cPlayer.

Definition at line 487 of file Entity.h.

◆ IsEnderCrystal()

bool cEntity::IsEnderCrystal ( void  ) const
inline

Definition at line 159 of file Entity.h.

◆ IsExpOrb()

bool cEntity::IsExpOrb ( void  ) const
inline

Definition at line 169 of file Entity.h.

◆ IsFallingBlock()

bool cEntity::IsFallingBlock ( void  ) const
inline

Definition at line 164 of file Entity.h.

◆ IsFireproof()

virtual bool cEntity::IsFireproof ( void  ) const
inlinevirtual

Reimplemented in cPawn, and cPlayer.

Definition at line 412 of file Entity.h.

◆ IsFloater()

bool cEntity::IsFloater ( void  ) const
inline

Definition at line 170 of file Entity.h.

◆ IsHeadInWater()

virtual bool cEntity::IsHeadInWater ( void  ) const
inlinevirtual

Returns true if any part of the entity is in a water block.

Definition at line 504 of file Entity.h.

◆ IsInFire()

virtual bool cEntity::IsInFire ( void  ) const
inlinevirtual

Returns true if any part of the entity is in a fire block.

Definition at line 495 of file Entity.h.

◆ IsInLava()

virtual bool cEntity::IsInLava ( void  ) const
inlinevirtual

Returns true if any part of the entity is in a lava block.

Definition at line 498 of file Entity.h.

◆ IsInvisible()

virtual bool cEntity::IsInvisible ( void  ) const
inlinevirtual

Reimplemented in cPlayer, and cPawn.

Definition at line 488 of file Entity.h.

◆ IsInWater()

virtual bool cEntity::IsInWater ( void  ) const
inlinevirtual

Returns true if any part of the entity is in a water block.

Definition at line 501 of file Entity.h.

◆ IsItemFrame()

bool cEntity::IsItemFrame ( void  ) const
inline

Definition at line 171 of file Entity.h.

◆ IsLeashKnot()

bool cEntity::IsLeashKnot ( void  ) const
inline

Definition at line 172 of file Entity.h.

◆ IsMinecart()

bool cEntity::IsMinecart ( void  ) const
inline

Definition at line 165 of file Entity.h.

◆ IsMob()

bool cEntity::IsMob ( void  ) const
inline

Definition at line 162 of file Entity.h.

◆ IsOnFire()

virtual bool cEntity::IsOnFire ( void  ) const
inlinevirtual

Definition at line 489 of file Entity.h.

◆ IsOnGround()

virtual bool cEntity::IsOnGround ( void  ) const
inlinevirtual

Returns whether the entity is on ground or not.

Reimplemented in cPlayer.

Definition at line 519 of file Entity.h.

◆ IsOrientationDirty()

bool cEntity::IsOrientationDirty ( ) const

Returns whether the entity's orientation has been set manually.

Primarily inteded for protocol use.

Definition at line 2093 of file Entity.cpp.

◆ IsPainting()

bool cEntity::IsPainting ( void  ) const
inline

Definition at line 173 of file Entity.h.

◆ IsPawn()

bool cEntity::IsPawn ( void  ) const
inline

Definition at line 163 of file Entity.h.

◆ IsPickup()

bool cEntity::IsPickup ( void  ) const
inline

Definition at line 161 of file Entity.h.

◆ IsPlayer()

bool cEntity::IsPlayer ( void  ) const
inline

Definition at line 160 of file Entity.h.

◆ IsProjectile()

bool cEntity::IsProjectile ( void  ) const
inline

Definition at line 168 of file Entity.h.

◆ IsRclking()

virtual bool cEntity::IsRclking ( void  ) const
inlinevirtual

Reimplemented in cPlayer.

Definition at line 490 of file Entity.h.

◆ IsRiding()

virtual bool cEntity::IsRiding ( void  ) const
inlinevirtual

Definition at line 491 of file Entity.h.

◆ IsSprinting()

virtual bool cEntity::IsSprinting ( void  ) const
inlinevirtual

Reimplemented in cPlayer.

Definition at line 492 of file Entity.h.

◆ IsTicking()

bool cEntity::IsTicking ( void  ) const

Returns true if the entity is valid and ticking.

Returns false if the entity is not ticking and is about to leave its current world either via teleportation or destruction. If this returns false, you must stop using the cEntity pointer you have.

Definition at line 2259 of file Entity.cpp.

◆ IsTNT()

bool cEntity::IsTNT ( void  ) const
inline

Definition at line 167 of file Entity.h.

◆ IsWorldChangeScheduled()

bool cEntity::IsWorldChangeScheduled ( ) const
inline

Returns true if a world change is scheduled to happen.

Definition at line 450 of file Entity.h.

◆ Killed()

virtual void cEntity::Killed ( const cEntity a_Victim,
eDamageType  a_DamageType 
)
inlinevirtual

Called when the entity kills another entity.

Reimplemented in cPlayer.

Definition at line 361 of file Entity.h.

◆ KilledBy()

void cEntity::KilledBy ( TakeDamageInfo a_TDI)
virtual

Called when the health drops below zero.

a_TDI's Attacker may be nullptr (environmental damage)

Reimplemented in cZombiePigman, cWither, cVillager, cSlime, cMonster, cPlayer, cPawn, cPainting, cMinecart, cLeashKnot, cHangingEntity, and cEnderCrystal.

Definition at line 851 of file Entity.cpp.

◆ MoveToWorld() [1/4]

bool cEntity::MoveToWorld ( const AString a_WorldName,
bool  a_ShouldSendRespawn = true 
)

Moves entity to specified world, taking a world name.

Definition at line 1686 of file Entity.cpp.

◆ MoveToWorld() [2/4]

bool cEntity::MoveToWorld ( cWorld a_World,
bool  a_ShouldSendRespawn,
Vector3d  a_NewPosition 
)
inline

Definition at line 436 of file Entity.h.

◆ MoveToWorld() [3/4]

bool cEntity::MoveToWorld ( cWorld a_World,
bool  a_ShouldSendRespawn = true 
)

Moves entity to specified world, taking a world pointer.

Definition at line 1677 of file Entity.cpp.

◆ MoveToWorld() [4/4]

bool cEntity::MoveToWorld ( cWorld a_World,
Vector3d  a_NewPosition,
bool  a_ShouldSetPortalCooldown = false,
bool  a_ShouldSendRespawn = true 
)

Definition at line 1616 of file Entity.cpp.

◆ OnAcquireSpectator()

void cEntity::OnAcquireSpectator ( cPlayer a_Player)

Called when a player begins spectating this entity.

Definition at line 138 of file Entity.cpp.

◆ OnAddToWorld()

void cEntity::OnAddToWorld ( cWorld a_World)
virtual

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 in cPlayer.

Definition at line 147 of file Entity.cpp.

◆ OnDetach()

void cEntity::OnDetach ( )
protectedvirtual

Called when this entity dismounts from m_AttachedTo.

Reimplemented in cPlayer.

Definition at line 2341 of file Entity.cpp.

◆ OnFinishedBurning()

void cEntity::OnFinishedBurning ( void  )
virtual

Called when the entity finishes burning.

Definition at line 1877 of file Entity.cpp.

◆ OnLoseSpectator()

void cEntity::OnLoseSpectator ( cPlayer a_Player)

Called when a player stops spectating this entity.

Definition at line 159 of file Entity.cpp.

◆ OnRemoveFromWorld()

void cEntity::OnRemoveFromWorld ( cWorld a_World)
virtual

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 in cMonster, cHorse, cPlayer, cPawn, cMinecartWithChest, and cMinecart.

Definition at line 172 of file Entity.cpp.

◆ OnRightClicked()

virtual void cEntity::OnRightClicked ( cPlayer a_Player)
inlinevirtual

Called when the specified player right-clicks this entity.

Reimplemented in cZombieVillager, cWolf, cSheep, cPig, cPassiveMonster, cOcelot, cMooshroom, cMonster, cHorse, cCreeper, cCow, cMinecartWithFurnace, cMinecartWithChest, cRideableMinecart, cLeashKnot, cItemFrame, and cBoat.

Definition at line 524 of file Entity.h.

◆ OnStartedBurning()

void cEntity::OnStartedBurning ( void  )
virtual

Called when the entity starts burning.

Definition at line 1867 of file Entity.cpp.

◆ RemoveLeashedMob()

void cEntity::RemoveLeashedMob ( cMonster a_Monster)

Removes a mob from the leashed list of mobs.

Definition at line 2311 of file Entity.cpp.

◆ ResetPosition()

void cEntity::ResetPosition ( Vector3d  a_NewPos)
protectedvirtual

Set the entities position and last sent position.

Only to be used when the caller will broadcast a teleport or equivalent to clients.

Reimplemented in cPawn.

Definition at line 1857 of file Entity.cpp.

◆ SetAirDrag()

void cEntity::SetAirDrag ( float  a_AirDrag)
inline

Definition at line 286 of file Entity.h.

◆ SetGravity()

void cEntity::SetGravity ( float  a_Gravity)
inline

Definition at line 282 of file Entity.h.

◆ SetHeadYaw()

void cEntity::SetHeadYaw ( double  a_HeadYaw)

Definition at line 2102 of file Entity.cpp.

◆ SetHealth()

void cEntity::SetHealth ( float  a_Health)

Sets the health of this entity; doesn't broadcast any hurt animation.

Definition at line 900 of file Entity.cpp.

◆ SetInvulnerableTicks()

void cEntity::SetInvulnerableTicks ( int  a_InvulnerableTicks)
inline

Set the invulnerable ticks from the entity.

Definition at line 516 of file Entity.h.

◆ SetIsFireproof()

void cEntity::SetIsFireproof ( bool  a_IsFireproof)

Sets whether the entity is fireproof.

Definition at line 1899 of file Entity.cpp.

◆ SetIsTicking()

void cEntity::SetIsTicking ( bool  a_IsTicking)

Set the entity's status to either ticking or not ticking.

Definition at line 1778 of file Entity.cpp.

◆ SetMass()

void cEntity::SetMass ( double  a_Mass)

Definition at line 2113 of file Entity.cpp.

◆ SetMaxHealth()

void cEntity::SetMaxHealth ( float  a_MaxHealth)

Sets the maximum value for the health.

Definition at line 1887 of file Entity.cpp.

◆ SetParentChunk()

void cEntity::SetParentChunk ( cChunk a_Chunk)

Sets the parent chunk, which is the chunk responsible for ticking this entity.

Only cChunk::AddEntity and cChunk::RemoveEntity cChunk::~cChunk should ever call this.

Definition at line 234 of file Entity.cpp.

◆ SetPitch()

void cEntity::SetPitch ( double  a_Pitch)

Definition at line 2136 of file Entity.cpp.

◆ SetPitchFromSpeed()

void cEntity::SetPitchFromSpeed ( void  )

Sets the pitch to match the speed vector (entity gies "face-forward")

Definition at line 387 of file Entity.cpp.

◆ SetPosition() [1/2]

void cEntity::SetPosition ( const Vector3d a_Position)

Definition at line 2281 of file Entity.cpp.

◆ SetPosition() [2/2]

void cEntity::SetPosition ( double  a_PosX,
double  a_PosY,
double  a_PosZ 
)
inline

Definition at line 218 of file Entity.h.

◆ SetPosX()

void cEntity::SetPosX ( double  a_PosX)
inline

Definition at line 215 of file Entity.h.

◆ SetPosY()

void cEntity::SetPosY ( double  a_PosY)
inline

Definition at line 216 of file Entity.h.

◆ SetPosZ()

void cEntity::SetPosZ ( double  a_PosZ)
inline

Definition at line 217 of file Entity.h.

◆ SetRoll()

void cEntity::SetRoll ( double  a_Roll)

Definition at line 2147 of file Entity.cpp.

◆ SetSize()

void cEntity::SetSize ( float  a_Width,
float  a_Height 
)

Update an entity's size, for example, on body stance changes.

Definition at line 1788 of file Entity.cpp.

◆ SetSpeed() [1/2]

void cEntity::SetSpeed ( double  a_SpeedX,
double  a_SpeedY,
double  a_SpeedZ 
)

Sets the speed of the entity, measured in m / sec.

Definition at line 2157 of file Entity.cpp.

◆ SetSpeed() [2/2]

void cEntity::SetSpeed ( Vector3d  a_Speed)
inline

Sets the speed of the entity, measured in m / sec.

Definition at line 228 of file Entity.h.

◆ SetSpeedX()

void cEntity::SetSpeedX ( double  a_SpeedX)

Sets the speed in the X axis, leaving the other speed components intact.

Measured in m / sec.

Definition at line 2167 of file Entity.cpp.

◆ SetSpeedY()

void cEntity::SetSpeedY ( double  a_SpeedY)

Sets the speed in the Y axis, leaving the other speed components intact.

Measured in m / sec.

Definition at line 2176 of file Entity.cpp.

◆ SetSpeedZ()

void cEntity::SetSpeedZ ( double  a_SpeedZ)

Sets the speed in the Z axis, leaving the other speed components intact.

Measured in m / sec.

Definition at line 2185 of file Entity.cpp.

◆ SetSwimState()

void cEntity::SetSwimState ( cChunk a_Chunk)
protectedvirtual

Called once per tick to set m_IsInFire, m_IsInLava, m_IsInWater and m_IsHeadInWater.

Reimplemented in cIronGolem, and cGuardian.

Definition at line 1702 of file Entity.cpp.

◆ SetWorld()

void cEntity::SetWorld ( cWorld a_World)
inline

Sets the internal world pointer to a new cWorld, doesn't update anything else.

Definition at line 534 of file Entity.h.

◆ SetYaw()

void cEntity::SetYaw ( double  a_Yaw)

Definition at line 2125 of file Entity.cpp.

◆ SetYawFromSpeed()

void cEntity::SetYawFromSpeed ( void  )

Sets the rotation to match the speed vector (entity goes "face-forward")

Definition at line 371 of file Entity.cpp.

◆ SpawnOn()

virtual void cEntity::SpawnOn ( cClientHandle a_Client)
pure virtual

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()

Implemented in cZombiePigman, cWitherSkeleton, cSkeleton, cMonster, cTNTEntity, cPickup, cMinecart, cLeashKnot, cItemFrame, cHangingEntity, cFallingBlock, cEnderCrystal, cBoat, cWither, cEnderDragon, cPlayer, cPainting, cFloater, cExpOrb, and cProjectileEntity.

◆ StartBurning()

void cEntity::StartBurning ( int  a_TicksLeftBurning)

Puts the entity on fire for the specified amount of ticks.

Definition at line 1908 of file Entity.cpp.

◆ SteerVehicle()

void cEntity::SteerVehicle ( float  a_Forward,
float  a_Sideways 
)

Definition at line 2243 of file Entity.cpp.

◆ StopBurning()

void cEntity::StopBurning ( void  )

Stops the entity from burning, resets all burning timers.

Definition at line 1925 of file Entity.cpp.

◆ TakeDamage() [1/4]

void cEntity::TakeDamage ( cEntity a_Attacker)

Makes this pawn take damage from an attack by a_Attacker.

Damage values are calculated automatically and DoTakeDamage() called

Definition at line 272 of file Entity.cpp.

◆ TakeDamage() [2/4]

void cEntity::TakeDamage ( eDamageType  a_DamageType,
cEntity a_Attacker,
int  a_RawDamage,
double  a_KnockbackAmount 
)

Makes this entity take the specified damage.

The final damage is calculated using current armor, then DoTakeDamage() called

Definition at line 282 of file Entity.cpp.

◆ TakeDamage() [3/4]

void cEntity::TakeDamage ( eDamageType  a_DamageType,
cEntity a_Attacker,
int  a_RawDamage,
float  a_FinalDamage,
double  a_KnockbackAmount 
)

Makes this entity take the specified damage.

The values are packed into a TDI, knockback calculated, then sent through DoTakeDamage()

Definition at line 320 of file Entity.cpp.

◆ TakeDamage() [4/4]

void cEntity::TakeDamage ( eDamageType  a_DamageType,
UInt32  a_Attacker,
int  a_RawDamage,
double  a_KnockbackAmount 
)

Makes this entity take the specified damage.

The final damage is calculated using current armor, then DoTakeDamage() called

Definition at line 296 of file Entity.cpp.

◆ TeleportToCoords()

void cEntity::TeleportToCoords ( double  a_PosX,
double  a_PosY,
double  a_PosZ 
)
virtual

Teleports to the coordinates specified.

Reimplemented in cPlayer.

Definition at line 1953 of file Entity.cpp.

◆ TeleportToEntity()

void cEntity::TeleportToEntity ( cEntity a_Entity)
virtual

Teleports to the entity specified.

Definition at line 1944 of file Entity.cpp.

◆ Tick()

void cEntity::Tick ( std::chrono::milliseconds  a_Dt,
cChunk a_Chunk 
)
virtual

◆ TickBurning()

void cEntity::TickBurning ( cChunk a_Chunk)
virtual

Updates the state related to this entity being on fire.

Definition at line 1251 of file Entity.cpp.

◆ TickInVoid()

void cEntity::TickInVoid ( cChunk a_Chunk)
virtual

Handles when the entity is in the void.

Definition at line 1346 of file Entity.cpp.

◆ WrapHeadYaw()

void cEntity::WrapHeadYaw ( void  )

Makes sure head yaw is not over the specified range.

Definition at line 204 of file Entity.cpp.

◆ WrapRotation()

void cEntity::WrapRotation ( void  )

Makes sure rotation is not over the specified range.

Definition at line 213 of file Entity.cpp.

◆ WrapSpeed()

void cEntity::WrapSpeed ( void  )

Makes speed is not over 20.

Max speed is 20 blocks / second

Definition at line 223 of file Entity.cpp.

Member Data Documentation

◆ BURN_DAMAGE

const int cEntity::BURN_DAMAGE = 1
static

Damage to deal when the entity is burning.

Definition at line 117 of file Entity.h.

◆ BURN_TICKS

const int cEntity::BURN_TICKS = 160
static

Ticks to keep an entity burning after it has stood in lava / fire.

Definition at line 119 of file Entity.h.

◆ BURN_TICKS_PER_DAMAGE

const int cEntity::BURN_TICKS_PER_DAMAGE = 20
static

Ticks to wait between damaging an entity when it is burning.

Definition at line 116 of file Entity.h.

◆ DROWNING_TICKS

const int cEntity::DROWNING_TICKS = 20
static

Number of ticks per heart of damage.

Definition at line 122 of file Entity.h.

◆ FALL_DAMAGE_HEIGHT

const int cEntity::FALL_DAMAGE_HEIGHT = 4
static

Y difference after which fall damage is applied.

Definition at line 125 of file Entity.h.

◆ FIRE_DAMAGE

const int cEntity::FIRE_DAMAGE = 1
static

Damage to deal when standing in fire.

Definition at line 113 of file Entity.h.

◆ FIRE_TICKS_PER_DAMAGE

const int cEntity::FIRE_TICKS_PER_DAMAGE = 10
static

Ticks to wait between damaging an entity when it stands in fire.

Definition at line 112 of file Entity.h.

◆ INVALID_ID

const UInt32 cEntity::INVALID_ID = 0
static

Special ID that is considered an "invalid value", signifying no entity.

Definition at line 128 of file Entity.h.

◆ LAVA_DAMAGE

const int cEntity::LAVA_DAMAGE = 4
static

Damage to deal when standing in lava.

Definition at line 115 of file Entity.h.

◆ LAVA_TICKS_PER_DAMAGE

const int cEntity::LAVA_TICKS_PER_DAMAGE = 10
static

Ticks to wait between damaging an entity when it stands in lava.

Definition at line 114 of file Entity.h.

◆ m_AirDrag

float cEntity::m_AirDrag
protected

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.wiki/w/Entity#Motion_of_entities.

Definition at line 614 of file Entity.h.

◆ m_AirLevel

int cEntity::m_AirLevel
protected

Air level of a mobile.

Definition at line 660 of file Entity.h.

◆ m_AirTickTimer

int cEntity::m_AirTickTimer
protected

Definition at line 661 of file Entity.h.

◆ m_AttachedTo

cEntity* cEntity::m_AttachedTo
protected

The entity to which this entity is attached (vehicle), nullptr if none.

Definition at line 588 of file Entity.h.

◆ m_Attachee

cEntity* cEntity::m_Attachee
protected

The entity which is attached to this entity (rider), nullptr if none.

Definition at line 591 of file Entity.h.

◆ m_bDirtyHead

bool cEntity::m_bDirtyHead
protected

Stores whether head yaw has been set manually.

Definition at line 594 of file Entity.h.

◆ m_bDirtyOrientation

bool cEntity::m_bDirtyOrientation
protected

Stores whether our yaw / pitch / roll (body orientation) has been set manually.

Definition at line 597 of file Entity.h.

◆ m_bHasSentNoSpeed

bool cEntity::m_bHasSentNoSpeed
protected

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.

Definition at line 601 of file Entity.h.

◆ m_bOnGround

bool cEntity::m_bOnGround
protected

Stores if the entity is on the ground.

Definition at line 604 of file Entity.h.

◆ m_EntityType

eEntityType cEntity::m_EntityType
protected

Definition at line 622 of file Entity.h.

◆ m_Gravity

float cEntity::m_Gravity
protected

Stores gravity that is applied to an entity every tick For realistic effects, this should be negative.

For spaaaaaaace, this can be zero or even positive

Definition at line 608 of file Entity.h.

◆ m_HeadYaw

double cEntity::m_HeadYaw
private

Measured in degrees, [-180, +180)

Definition at line 704 of file Entity.h.

◆ m_Health

float cEntity::m_Health
protected

Definition at line 584 of file Entity.h.

◆ m_Height

float cEntity::m_Height
private

Height of the entity (Y axis).

Definition at line 722 of file Entity.h.

◆ m_InvulnerableTicks

int cEntity::m_InvulnerableTicks
private

If a player hit a entity, the entity receive a invulnerable of 10 ticks.

While this ticks, a player can't hit this entity.

Definition at line 726 of file Entity.h.

◆ m_IsFireproof

bool cEntity::m_IsFireproof
protected

Whether the entity is capable of taking fire or lava damage.

Definition at line 630 of file Entity.h.

◆ m_IsHeadInWater

bool cEntity::m_IsHeadInWater
protected

If the entity's head is in a water block.

Definition at line 657 of file Entity.h.

◆ m_IsInFire

bool cEntity::m_IsInFire
protected

If any part of the entity is in a fire block.

Definition at line 648 of file Entity.h.

◆ m_IsInLava

bool cEntity::m_IsInLava
protected

If any part of the entity is in a lava block.

Definition at line 651 of file Entity.h.

◆ m_IsInWater

bool cEntity::m_IsInWater
protected

If any part of the entity is in a water block.

Definition at line 654 of file Entity.h.

◆ m_IsTicking

bool cEntity::m_IsTicking
private

Whether the entity is ticking or not.

If not, it is scheduled for removal or world-teleportation.

Definition at line 698 of file Entity.h.

◆ m_LastPosition

Vector3d cEntity::m_LastPosition
protected

Definition at line 620 of file Entity.h.

◆ m_LastSentPosition

Vector3d cEntity::m_LastSentPosition
protected

Last position sent to client via the Relative Move or Teleport packets (not Velocity) Only updated if cEntity::BroadcastMovementUpdate() is called!

Definition at line 618 of file Entity.h.

◆ m_LeashedMobs

cMonsterList cEntity::m_LeashedMobs
private

List of leashed mobs to this entity.

Definition at line 731 of file Entity.h.

◆ m_Mass

double cEntity::m_Mass
private

Measured in Kilograms (Kg)

Definition at line 716 of file Entity.h.

◆ m_MaxHealth

float cEntity::m_MaxHealth
protected

Definition at line 585 of file Entity.h.

◆ m_ParentChunk

cChunk* cEntity::m_ParentChunk
private

The chunk which is responsible for ticking this entity.

Definition at line 701 of file Entity.h.

◆ m_PortalCooldownData

sPortalCooldownData cEntity::m_PortalCooldownData
protected

Portal delay timer and cooldown boolean data.

Definition at line 664 of file Entity.h.

◆ m_Position

Vector3d cEntity::m_Position
private

Position of the entity's XZ center and Y bottom.

Definition at line 710 of file Entity.h.

◆ m_Rot

Vector3d cEntity::m_Rot
private

Measured in degrees, [-180, +180)

Definition at line 707 of file Entity.h.

◆ m_Spectators

std::vector<cPlayer *> cEntity::m_Spectators
private

List of players who are spectating this entity.

Definition at line 734 of file Entity.h.

◆ m_Speed

Vector3d cEntity::m_Speed
protected

Measured in meters / second (m / s)

Definition at line 577 of file Entity.h.

◆ m_TicksAlive

long int cEntity::m_TicksAlive
protected

The number of ticks this entity has been alive for.

Definition at line 667 of file Entity.h.

◆ m_TicksLeftBurning

int cEntity::m_TicksLeftBurning
protected

Time, in ticks, until the entity extinguishes its fire.

Definition at line 642 of file Entity.h.

◆ m_TicksSinceLastBurnDamage

int cEntity::m_TicksSinceLastBurnDamage
protected

Time, in ticks, since the last damage dealt by being on fire.

Valid only if on fire (IsOnFire())

Definition at line 633 of file Entity.h.

◆ m_TicksSinceLastFireDamage

int cEntity::m_TicksSinceLastFireDamage
protected

Time, in ticks, since the last damage dealt by standing in fire.

Reset to zero when moving out of fire.

Definition at line 639 of file Entity.h.

◆ m_TicksSinceLastLavaDamage

int cEntity::m_TicksSinceLastLavaDamage
protected

Time, in ticks, since the last damage dealt by standing in lava.

Reset to zero when moving out of lava.

Definition at line 636 of file Entity.h.

◆ m_TicksSinceLastVoidDamage

int cEntity::m_TicksSinceLastVoidDamage
protected

Time, in ticks, since the last damage dealt by the void.

Reset to zero when moving out of the void.

Definition at line 645 of file Entity.h.

◆ m_UniqueID

UInt32 cEntity::m_UniqueID
protected

The ID of the entity that is guaranteed to be unique within a single run of the server.

Always nonzero (a zero UniqueID (cEntity::INVALID_ID) is used for error reporting). Note that the UniqueID is not persisted through storage.

Definition at line 582 of file Entity.h.

◆ m_WaterSpeed

Vector3d cEntity::m_WaterSpeed
private

Measured in meter / second.

Definition at line 713 of file Entity.h.

◆ m_Width

float cEntity::m_Width
private

Width of the entity, in the XZ plane.

Since entities are represented as cylinders, this is more of a diameter.

Definition at line 719 of file Entity.h.

◆ m_World

cWorld* cEntity::m_World
protected

Definition at line 624 of file Entity.h.

◆ m_WorldChangeInfo

sWorldChangeInfo cEntity::m_WorldChangeInfo
protected

If field m_NewWorld not nullptr, a world change is scheduled and a task is queued in the current world.

Definition at line 627 of file Entity.h.

◆ MAX_AIR_LEVEL

const int cEntity::MAX_AIR_LEVEL = 300
static

Maximum air an entity can have.

Definition at line 121 of file Entity.h.

◆ VOID_BOUNDARY

const int cEntity::VOID_BOUNDARY = -64
static

Y position to begin applying void damage.

Definition at line 124 of file Entity.h.


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