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

#include <Pawn.h>

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

Public Member Functions

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...
 
virtual bool IsFireproof (void) const override
 
virtual bool IsInvisible () const override
 
virtual void KilledBy (TakeDamageInfo &a_TDI) override
 Called when the health drops below zero. More...
 
void NoLongerTargetingMe (cMonster *a_Monster)
 Remove the monster from the list of monsters targeting this pawn. More...
 
virtual void OnRemoveFromWorld (cWorld &a_World) override
 Called when the entity is removed from a world. 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...
 
virtual void Tick (std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
 
- 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 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
 
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
 
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...
 
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 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 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 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...
 

Protected Types

typedef std::map< cEntityEffect::eType, std::unique_ptr< cEntityEffect > > tEffectMap
 

Protected Member Functions

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 OnDetach ()
 Called when this entity dismounts from m_AttachedTo. More...
 
virtual void SetSwimState (cChunk &a_Chunk)
 Called once per tick to set m_IsInFire, m_IsInLava, m_IsInWater and m_IsHeadInWater. More...
 

Protected Attributes

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

using Super = cEntity
 

Private Member Functions

bool DeductTotem (eDamageType a_DamageType)
 Attempt to activate a Totem of Undying. More...
 

Private Attributes

std::vector< cMonster * > m_TargetingMe
 A list of all monsters that are targeting this pawn. 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
}
 
- 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...
 
- 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...
 

Detailed Description

Definition at line 15 of file Pawn.h.

Member Typedef Documentation

◆ Super

using cPawn::Super = cEntity
private

Definition at line 19 of file Pawn.h.

◆ tEffectMap

typedef std::map<cEntityEffect::eType, std::unique_ptr<cEntityEffect> > cPawn::tEffectMap
protected

Definition at line 101 of file Pawn.h.

Constructor & Destructor Documentation

◆ cPawn()

cPawn::cPawn ( eEntityType  a_EntityType,
float  a_Width,
float  a_Height 
)

Definition at line 18 of file Pawn.cpp.

Member Function Documentation

◆ AddEntityEffect()

void cPawn::AddEntityEffect ( cEntityEffect::eType  a_EffectType,
int  a_EffectDurationTicks,
short  a_EffectIntensity,
double  a_DistanceModifier = 1 
)

Applies an entity effect.

Checks with plugins if they allow the addition. a_EffectIntensity is the level of the effect (0 = Potion I, 1 = Potion II, etc). a_DistanceModifier is the scalar multiplied to the potion duration (only applies to splash potions).

Definition at line 186 of file Pawn.cpp.

◆ ClearEntityEffects()

void cPawn::ClearEntityEffects ( void  )

Removes all currently applied entity effects (used when drinking milk)

Definition at line 245 of file Pawn.cpp.

◆ DeductTotem()

bool cPawn::DeductTotem ( eDamageType  a_DamageType)
private

Attempt to activate a Totem of Undying.

If activation for the given type of damage was successful, consumes the totem and returns true.

Definition at line 617 of file Pawn.cpp.

◆ FindTeleportDestination() [1/3]

bool cPawn::FindTeleportDestination ( cWorld a_World,
const int  a_HeightRequired,
const unsigned int  a_NumTries,
Vector3d a_Destination,
const cBoundingBox  a_BoundingBox 
)
static

Definition at line 710 of file Pawn.cpp.

◆ FindTeleportDestination() [2/3]

bool cPawn::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

Definition at line 652 of file Pawn.cpp.

◆ FindTeleportDestination() [3/3]

bool cPawn::FindTeleportDestination ( cWorld a_World,
const int  a_HeightRequired,
const unsigned int  a_NumTries,
Vector3d a_Destination,
Vector3i  a_Centre,
const int  a_HalfCubeWidth 
)
static

Used by enderman and chorus fruit.

Checks for valid destinations in a cube of length 2 * a_HalfCubeWidth centred at a_Centre. Returns true and places destination in a_Destination if successful. Returns false if destination could be found after a_NumTries attempts. Details at: https://minecraft.wiki/w/Enderman#Teleportation.

Definition at line 719 of file Pawn.cpp.

◆ GetEntityEffect()

cEntityEffect * cPawn::GetEntityEffect ( cEntityEffect::eType  a_EffectType) const

Returns the entity effect, if it is currently applied or nullptr if not.

Definition at line 597 of file Pawn.cpp.

◆ GetEntityEffects()

std::map< cEntityEffect::eType, cEntityEffect * > cPawn::GetEntityEffects ( ) const

Returns all entity effects.

Definition at line 583 of file Pawn.cpp.

◆ HandleAir()

void cPawn::HandleAir ( void  )
overridevirtual

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

drowning

Reimplemented from cEntity.

Reimplemented in cSquid, cIronGolem, and cGuardian.

Definition at line 171 of file Pawn.cpp.

◆ HandleFalling()

void cPawn::HandleFalling ( void  )
virtual

Reimplemented in cMonster.

Definition at line 297 of file Pawn.cpp.

◆ HandleFarmlandTrampling()

void cPawn::HandleFarmlandTrampling ( double  a_FallHeight,
BLOCKTYPE  a_BlockAtFoot,
BLOCKTYPE  a_BlockBelow 
)

Handles farmland trampling when hitting the ground.

Algorithm: fall height <= 0.6875 blocks: no trampling fall height > 0.6875 and <= 1.0625: 25% chance of trampling fall height > 1.0625 and <= 1.5625: 66% chance of trampling fall height > 1.5625: always trample The values may differ from vanilla, they were determined experimentally. Additionaly, mobs smaller than 0.512 cubic blocks won't trample.

Definition at line 490 of file Pawn.cpp.

◆ HasEntityEffect()

bool cPawn::HasEntityEffect ( cEntityEffect::eType  a_EffectType) const

Returns true, if the entity effect is currently applied.

Definition at line 236 of file Pawn.cpp.

◆ IsFireproof()

bool cPawn::IsFireproof ( void  ) const
overridevirtual

Reimplemented from cEntity.

Reimplemented in cPlayer.

Definition at line 153 of file Pawn.cpp.

◆ IsInvisible()

bool cPawn::IsInvisible ( void  ) const
overridevirtual

Reimplemented from cEntity.

Reimplemented in cPlayer.

Definition at line 162 of file Pawn.cpp.

◆ KilledBy()

void cPawn::KilledBy ( TakeDamageInfo a_TDI)
overridevirtual

Called when the health drops below zero.

a_TDI's Attacker may be nullptr (environmental damage)

Reimplemented from cEntity.

Reimplemented in cZombiePigman, cWither, cVillager, cSlime, cMonster, and cPlayer.

Definition at line 129 of file Pawn.cpp.

◆ NoLongerTargetingMe()

void cPawn::NoLongerTargetingMe ( cMonster a_Monster)

Remove the monster from the list of monsters targeting this pawn.

Definition at line 265 of file Pawn.cpp.

◆ OnRemoveFromWorld()

void cPawn::OnRemoveFromWorld ( cWorld a_World)
overridevirtual

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

Reimplemented in cMonster, cHorse, and cPlayer.

Definition at line 556 of file Pawn.cpp.

◆ RemoveEntityEffect()

void cPawn::RemoveEntityEffect ( cEntityEffect::eType  a_EffectType)

Removes a currently applied entity effect.

Definition at line 219 of file Pawn.cpp.

◆ ResetPosition()

void cPawn::ResetPosition ( Vector3d  a_NewPos)
overrideprotectedvirtual

Set the entities position and last sent position.

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

Reimplemented from cEntity.

Definition at line 607 of file Pawn.cpp.

◆ StopEveryoneFromTargetingMe()

void cPawn::StopEveryoneFromTargetingMe ( )

Tells all pawns which are targeting us to stop targeting us.

Definition at line 566 of file Pawn.cpp.

◆ TargetingMe()

void cPawn::TargetingMe ( cMonster a_Monster)

Add the monster to the list of monsters targeting this pawn.

(Does not check if already in list!)

Definition at line 285 of file Pawn.cpp.

◆ Tick()

void cPawn::Tick ( std::chrono::milliseconds  a_Dt,
cChunk a_Chunk 
)
overridevirtual

Member Data Documentation

◆ m_bTouchGround

bool cPawn::m_bTouchGround
protected

Definition at line 105 of file Pawn.h.

◆ m_EntityEffects

tEffectMap cPawn::m_EntityEffects
protected

Definition at line 102 of file Pawn.h.

◆ m_LastGroundHeight

double cPawn::m_LastGroundHeight
protected

Definition at line 104 of file Pawn.h.

◆ m_TargetingMe

std::vector<cMonster*> cPawn::m_TargetingMe
private

A list of all monsters that are targeting this pawn.

Definition at line 112 of file Pawn.h.


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