11 #define CLASS_PROTODEF(classname) \ 12 virtual bool IsA(const char * a_ClassName) const override\ 14 return ((a_ClassName != nullptr) && ((strcmp(a_ClassName, #classname) == 0) || super::IsA(a_ClassName))); \ 16 virtual const char * GetClass(void) const override \ 20 static const char * GetClassStatic(void) \ 24 virtual const char * GetParentClass(void) const override \ 26 return super::GetClass(); \ 29 #define POSX_TOINT FloorC(GetPosX()) 30 #define POSY_TOINT FloorC(GetPosY()) 31 #define POSZ_TOINT FloorC(GetPosZ()) 32 #define POS_TOINT GetPosition().Floor() 34 #define GET_AND_VERIFY_CURRENT_CHUNK(ChunkVarName, X, Z) \ 35 cChunk * ChunkVarName = a_Chunk.GetNeighborChunk(X, Z); \ 37 if ((ChunkVarName == nullptr) || !ChunkVarName->IsValid()) \ 110 esIronGolemAttacking = 4,
116 esWolfDryingWater = 8,
118 esPlayerEatingAccepted = 9,
122 esIronGolemGivingPlant = 11,
124 esVillagerBreeding = 12,
126 esVillagerAngry = 13,
128 esVillagerHappy = 14,
130 esWitchMagicking = 15,
135 esFireworkExploding = 17,
140 static const int FIRE_TICKS_PER_DAMAGE = 10;
141 static const int FIRE_DAMAGE = 1;
142 static const int LAVA_TICKS_PER_DAMAGE = 10;
143 static const int LAVA_DAMAGE = 4;
144 static const int BURN_TICKS_PER_DAMAGE = 20;
145 static const int BURN_DAMAGE = 1;
147 static const int BURN_TICKS = 160;
149 static const int MAX_AIR_LEVEL = 300;
150 static const int DROWNING_TICKS = 20;
152 static const int VOID_BOUNDARY = -64;
153 static const int FALL_DAMAGE_HEIGHT = 4;
171 bool IsPlayer (
void)
const {
return (m_EntityType == etPlayer); }
172 bool IsPickup (
void)
const {
return (m_EntityType == etPickup); }
173 bool IsMob (
void)
const {
return (m_EntityType == etMonster); }
174 bool IsPawn (
void)
const {
return (IsMob() || IsPlayer()); }
176 bool IsMinecart (
void)
const {
return (m_EntityType == etMinecart); }
177 bool IsBoat (
void)
const {
return (m_EntityType == etBoat); }
178 bool IsTNT (
void)
const {
return (m_EntityType == etTNT); }
179 bool IsProjectile (
void)
const {
return (m_EntityType == etProjectile); }
180 bool IsExpOrb (
void)
const {
return (m_EntityType == etExpOrb); }
181 bool IsFloater (
void)
const {
return (m_EntityType == etFloater); }
182 bool IsItemFrame (
void)
const {
return (m_EntityType == etItemFrame); }
183 bool IsLeashKnot (
void)
const {
return (m_EntityType == etLeashKnot); }
184 bool IsPainting (
void)
const {
return (m_EntityType == etPainting); }
187 virtual bool IsA(
const char * a_ClassName)
const;
190 static const char * GetClassStatic(
void);
193 virtual const char * GetClass(
void)
const;
196 virtual const char * GetParentClass(
void)
const;
205 double GetMass (
void)
const {
return m_Mass; }
206 double GetPosX (
void)
const {
return m_Position.x; }
207 double GetPosY (
void)
const {
return m_Position.y; }
208 double GetPosZ (
void)
const {
return m_Position.z; }
209 double GetYaw (
void)
const {
return m_Rot.x; }
211 double GetRoll (
void)
const {
return m_Rot.z; }
221 void SetHeadYaw (
double a_HeadYaw);
222 void SetMass (
double a_Mass);
223 void SetPosX (
double a_PosX) { SetPosition({a_PosX, m_Position.y, m_Position.z}); }
224 void SetPosY (
double a_PosY) { SetPosition({m_Position.x, a_PosY, m_Position.z}); }
225 void SetPosZ (
double a_PosZ) { SetPosition({m_Position.x, m_Position.y, a_PosZ}); }
227 void SetPosition(
const Vector3d & a_Position);
228 void SetYaw (
double a_Yaw);
229 void SetPitch (
double a_Pitch);
230 void SetRoll (
double a_Roll);
233 void SetSpeed(
double a_SpeedX,
double a_SpeedY,
double a_SpeedZ);
239 void SetSpeedX(
double a_SpeedX);
242 void SetSpeedY(
double a_SpeedY);
245 void SetSpeedZ(
double a_SpeedZ);
247 void AddPosX (
double a_AddPosX) { AddPosition(a_AddPosX, 0, 0); }
248 void AddPosY (
double a_AddPosY) { AddPosition(0, a_AddPosY, 0); }
249 void AddPosZ (
double a_AddPosZ) { AddPosition(0, 0, a_AddPosZ); }
250 void AddPosition(
double a_AddPosX,
double a_AddPosY,
double a_AddPosZ) { SetPosition(m_Position +
Vector3d(a_AddPosX, a_AddPosY, a_AddPosZ)); }
252 void AddSpeed (
double a_AddSpeedX,
double a_AddSpeedY,
double a_AddSpeedZ);
254 void AddSpeedX (
double a_AddSpeedX);
255 void AddSpeedY (
double a_AddSpeedY);
256 void AddSpeedZ (
double a_AddSpeedZ);
258 virtual void HandleSpeedFromAttachee(
float a_Forward,
float a_Sideways);
259 void SteerVehicle(
float a_Forward,
float a_Sideways);
269 bool IsTicking(
void)
const;
272 virtual void Destroy(
bool a_ShouldBroadcast =
true);
275 void TakeDamage(
cEntity & a_Attacker);
278 void TakeDamage(
eDamageType a_DamageType,
cEntity * a_Attacker,
int a_RawDamage,
double a_KnockbackAmount);
281 void TakeDamage(
eDamageType a_DamageType,
UInt32 a_Attacker,
int a_RawDamage,
double a_KnockbackAmount);
284 void TakeDamage(
eDamageType a_DamageType,
cEntity * a_Attacker,
int a_RawDamage,
float a_FinalDamage,
double a_KnockbackAmount);
295 void SetYawFromSpeed(
void);
298 void SetPitchFromSpeed(
void);
302 void SetHeight(
double a_Height);
304 void SetWidth(
double a_Width);
317 void DestroyNoScheduling(
bool a_ShouldBroadcast);
327 virtual int GetRawDamageAgainst(
const cEntity & a_Receiver);
330 virtual bool ArmorCoversAgainst(
eDamageType a_DamageType);
333 virtual int GetArmorCoverAgainst(
const cEntity * a_Attacker,
eDamageType a_DamageType,
int a_RawDamage);
336 virtual int GetEnchantmentCoverAgainst(
const cEntity * a_Attacker,
eDamageType a_DamageType,
int a_Damage);
340 virtual float GetEnchantmentBlastKnockbackReduction();
343 virtual double GetKnockbackAmountAgainst(
const cEntity & a_Receiver);
364 virtual void ApplyArmorDamage(
int DamageBlocked);
377 virtual void Heal(
int a_HitPoints);
383 void SetHealth(
float a_Health);
387 virtual void Tick(std::chrono::milliseconds a_Dt,
cChunk & a_Chunk);
390 virtual void HandlePhysics(std::chrono::milliseconds a_Dt,
cChunk & a_Chunk);
393 virtual void TickBurning(
cChunk & a_Chunk);
396 virtual void DetectCacti(
void);
401 virtual bool DetectPortal(
void);
404 virtual void TickInVoid(
cChunk & a_Chunk);
407 virtual void OnStartedBurning(
void);
410 virtual void OnFinishedBurning(
void);
415 void SetMaxHealth(
float a_MaxHealth);
420 void SetIsFireproof(
bool a_IsFireproof);
425 void StartBurning(
int a_TicksLeftBurning);
428 void StopBurning(
void);
439 virtual void TeleportToEntity(
cEntity & a_Entity);
442 virtual void TeleportToCoords(
double a_PosX,
double a_PosY,
double a_PosZ);
445 void ScheduleMoveToWorld(
cWorld * a_World,
Vector3d a_NewPosition,
bool a_ShouldSetPortalCooldown =
false,
bool a_ShouldSendRespawn =
false);
447 bool MoveToWorld(
cWorld * a_World,
bool a_ShouldSendRespawn,
Vector3d a_NewPosition);
450 bool MoveToWorld(
cWorld * a_World,
bool a_ShouldSendRespawn =
true);
453 bool MoveToWorld(
const AString & a_WorldName,
bool a_ShouldSendRespawn =
true);
457 virtual bool DoMoveToWorld(
cWorld * a_World,
bool a_ShouldSendRespawn,
Vector3d a_NewPosition);
460 virtual void BroadcastMovementUpdate(
const cClientHandle * a_Exclude =
nullptr);
466 virtual void AttachTo(
cEntity * a_AttachTo);
469 virtual void Detach(
void);
472 bool IsAttachedTo(
const cEntity * a_Entity)
const;
486 virtual bool IsOnFire (
void)
const {
return (m_TicksLeftBurning > 0); }
488 virtual bool IsRiding (
void)
const {
return false; }
494 virtual bool IsInFire(
void)
const {
return m_IsInFire; }
497 virtual bool IsInLava(
void)
const {
return m_IsInLava; }
500 virtual bool IsInWater(
void)
const {
return m_IsInWater; }
537 void SetParentChunk(
cChunk * a_Chunk);
544 void SetIsTicking(
bool a_IsTicking);
547 void AddLeashedMob(
cMonster * a_Monster);
550 void RemoveLeashedMob(
cMonster * a_Monster);
559 virtual float GetExplosionExposureRate(
Vector3d a_ExplosionPosition,
float a_ExlosionPower);
672 virtual void DoSetSpeed(
double a_SpeedX,
double a_SpeedY,
double a_SpeedZ);
679 static void ApplyFriction(
Vector3d & a_Speed,
double a_SlowdownMultiplier,
float a_Dt);
682 virtual void HandleAir(
void);
686 virtual void SetSwimState(
cChunk & a_Chunk);
690 virtual void ResetPosition(
Vector3d a_NewPos);
int GetChunkZ(void) const
virtual bool IsHeadInWater(void) const
Returns true if any part of the entity is in a water block.
double GetPosY(void) const
virtual bool IsRiding(void) const
bool IsFloater(void) const
double GetPitch(void) const
Vector3d m_LastSentPosition
Last position sent to client via the Relative Move or Teleport packets (not Velocity) Only updated if...
double GetPosX(void) const
bool m_IsHeadInWater
If the entity's head is in a water block.
eEntityType GetEntityType(void) const
int m_TicksSinceLastLavaDamage
Time, in ticks, since the last damage dealt by standing in lava.
sPortalCooldownData m_PortalCooldownData
Portal delay timer and cooldown boolean data.
int GetAirLevel(void) const
Gets remaining air of a monster.
cMonsterList m_LeashedMobs
List of leashed mobs to this entity.
virtual bool DoesPreventBlockPlacement(void) const
Returns whether blocks can be placed intersecting this entities' hitbox.
std::list< cMonster * > cMonsterList
cChunk * GetParentChunk()
Returns the chunk responsible for ticking this entity.
double GetHeadYaw(void) const
double GetSpeedX(void) const
void SetInvulnerableTicks(int a_InvulnerableTicks)
Set the invulnerable ticks from the entity.
virtual cItem GetOffHandEquipedItem(void) const
Returns the currently offhand equipped item; empty item if none.
virtual cItem GetEquippedHelmet(void) const
Returns the currently equipped helmet; empty item if none.
Vector3d m_WaterSpeed
Measured in meter / second.
bool m_WorldChangeSendRespawn
bool HasAnyMobLeashed() const
Returs whether the entity has any mob leashed to.
void SetPosition(double a_PosX, double a_PosY, double a_PosZ)
int m_TicksLeftBurning
Time, in ticks, until the entity extinguishes its fire.
bool m_IsInLava
If any part of the entity is in a lava block.
unsigned short m_TicksDelayed
Ticks since entry of portal, used to delay teleportation.
long int GetTicksAlive(void) const
Gets number of ticks this entity has existed for.
bool IsEnderCrystal(void) const
virtual bool IsOnFire(void) const
bool m_ShouldPreventTeleportation
Whether the entity has just exited the portal, and should therefore not be teleported again...
const Vector3d & GetSpeed(void) const
Exported in ManualBindings.
virtual cItem GetEquippedBoots(void) const
Returns the currently equipped boots; empty item if none.
bool m_IsTicking
Whether the entity is ticking or not.
bool m_bHasSentNoSpeed
Stores whether we have sent a Velocity packet with a speed of zero (no speed) to the client Ensures t...
bool IsProjectile(void) const
double m_Width
Width of the entity, in the XZ plane.
virtual bool IsInWater(void) const
Returns true if any part of the entity is in a water block.
UInt32 m_UniqueID
The ID of the entity that is guaranteed to be unique within a single run of the server.
virtual bool IsCrouched(void) const
void AddSpeed(const Vector3d &a_AddSpeed)
double GetSpeedZ(void) const
virtual void Destroyed(void)
cChunk * m_ParentChunk
The chunk which is responsible for ticking this entity.
double GetWidth(void) const
Vector3d m_NewWorldPosition
double GetRoll(void) const
virtual bool IsInvisible(void) const
float GetAirDrag(void) const
void SetPosY(double a_PosY)
int GetInvulnerableTicks(void) const
Gets the invulnerable ticks from the entity.
double GetHeight(void) const
bool m_bDirtyHead
Stores whether head yaw has been set manually.
float m_AirDrag
Stores the air drag that is applied to the entity every tick, measured in speed ratio per tick Acts a...
int m_InvulnerableTicks
If a player hit a entity, the entity receive a invulnerable of 10 ticks.
bool m_bDirtyOrientation
Stores whether our yaw / pitch / roll (body orientation) has been set manually.
bool m_IsFireproof
Whether the entity is capable of taking fire or lava damage.
double m_Height
Height of the entity (Y axis)
bool m_IsInFire
If any part of the entity is in a fire block.
virtual bool IsInFire(void) const
Returns true if any part of the entity is in a fire block.
int m_TicksSinceLastFireDamage
Time, in ticks, since the last damage dealt by standing in fire.
eDamageType
Damage type, used in the TakeDamageInfo structure and related functions.
void AddPosition(double a_AddPosX, double a_AddPosY, double a_AddPosZ)
virtual bool IsOnGround(void) const
Returns whether the entity is on ground or not.
bool m_WorldChangeSetPortalCooldown
virtual cItem GetEquippedLeggings(void) const
Returns the currently equipped leggings; empty item if none.
int m_TicksSinceLastBurnDamage
Time, in ticks, since the last damage dealt by being on fire.
bool IsMinecart(void) const
Structure storing the portal delay timer and cooldown boolean.
Vector3d m_Rot
Measured in degrees, [-180, +180)
Vector3< double > Vector3d
double m_Mass
Measured in Kilograms (Kg)
bool IsExpOrb(void) const
bool IsDestroyed() const
Deprecated.
void AddPosZ(double a_AddPosZ)
float GetHealth(void) const
Returns the health of this entity.
float GetGravity(void) const
bool IsItemFrame(void) const
Vector3d GetLastSentPos(void) const
Returns the last position we sent to all the clients.
void SetWorld(cWorld *a_World)
Sets the internal world pointer to a new cWorld, doesn't update anything else.
virtual void GetDrops(cItems &a_Drops, cEntity *a_Killer=nullptr)
Returns the list of drops for this pawn when it is killed.
float GetMaxHealth(void) const
void AddPosition(const Vector3d &a_AddPos)
int m_AirLevel
Air level of a mobile.
void SetGravity(float a_Gravity)
virtual void OnRightClicked(cPlayer &a_Player)
Called when the specified player right-clicks this entity.
double m_HeadYaw
Measured in degrees, [-180, +180)
double GetYaw(void) const
int m_TicksSinceLastVoidDamage
Time, in ticks, since the last damage dealt by the void.
virtual bool IsSprinting(void) const
cEntity * m_AttachedTo
The entity to which this entity is attached (vehicle), nullptr if none.
bool IsPlayer(void) const
double GetSpeedY(void) const
int GetChunkX(void) const
virtual cItem GetEquippedWeapon(void) const
Returns the curently equipped weapon; empty item if none.
virtual void Killed(cEntity *a_Victim)
Called when the entity kills another entity.
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
bool IsPickup(void) const
Vector3d m_Position
Position of the entity's XZ center and Y bottom.
float m_Gravity
Stores gravity that is applied to an entity every tick For realistic effects, this should be negative...
std::unique_ptr< cEntity > OwnedEntity
void SetAirDrag(float a_AirDrag)
cEntity * m_Attachee
The entity which is attached to this entity (rider), nullptr if none.
virtual bool IsRclking(void) const
bool m_bOnGround
Stores if the entity is on the ground.
bool m_IsInWater
If any part of the entity is in a water block.
double GetPosZ(void) const
void AddPosY(double a_AddPosY)
virtual bool IsFireproof(void) const
void AddPosX(double a_AddPosX)
Vector3d m_Speed
Measured in meters / second (m / s)
void SetPosX(double a_PosX)
bool IsFallingBlock(void) const
std::enable_if< std::is_arithmetic< T >::value, C >::type FloorC(T a_Value)
Floors a value, then casts it to C (an int by default)
void SetSpeed(Vector3d a_Speed)
Sets the speed of the entity, measured in m / sec.
virtual cItem GetEquippedChestplate(void) const
Returns the currently equipped chestplate; empty item if none.
void SetPosZ(double a_PosZ)
long int m_TicksAlive
The number of ticks this entity has been alive for.
bool m_IsWorldChangeScheduled
State variables for ScheduleMoveToWorld.
bool IsLeashKnot(void) const
UInt32 GetUniqueID(void) const
cWorld * GetWorld(void) const
This class bridges a vector of cItem for safe access via Lua.
double GetMass(void) const
bool IsPainting(void) const
virtual bool IsInLava(void) const
Returns true if any part of the entity is in a lava block.
const cChunk * GetParentChunk() const