Cuberite
A lightweight, fast and extensible game server for Minecraft
ThrownSnowballEntity.cpp
Go to the documentation of this file.
1 #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
2 
3 #include "ThrownSnowballEntity.h"
4 #include "../World.h"
5 
6 
7 
8 
9 
11  Super(pkSnowball, a_Creator, a_Pos, a_Speed, 0.25f, 0.25f)
12 {
13 }
14 
15 
16 
17 
18 
20 {
21  Super::OnHitEntity(a_EntityHit, a_HitPos);
22 
23  int Damage = 0;
24  if (a_EntityHit.IsMob() && (static_cast<cMonster &>(a_EntityHit).GetMobType() == mtBlaze))
25  {
26  // Blazes take 3 damage:
27  Damage = 3;
28  }
29  else if (a_EntityHit.IsEnderCrystal())
30  {
31  // Endercrystals are destroyed:
32  Damage = CeilC(a_EntityHit.GetHealth());
33  }
34 
35  a_EntityHit.TakeDamage(dtRangedAttack, GetCreatorUniqueID(), Damage, 1);
37  Destroy();
38 }
39 
40 
41 
42 
43 
45 {
46  Super::OnHitSolidBlock(a_HitPos, a_HitFace);
47 
49  Destroy();
50 }
@ dtRangedAttack
Definition: Defines.h:247
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
Definition: Defines.h:38
std::enable_if< std::is_arithmetic< T >::value, C >::type CeilC(T a_Value)
Ceils a value, then casts it to C (an int by default).
Definition: Globals.h:354
@ mtBlaze
Definition: MonsterTypes.h:15
Definition: Entity.h:76
bool IsEnderCrystal(void) const
Definition: Entity.h:159
cWorld * m_World
Definition: Entity.h:624
void Destroy()
Destroys the entity, schedules it for memory freeing and broadcasts the DestroyEntity packet.
Definition: Entity.cpp:243
void TakeDamage(cEntity &a_Attacker)
Makes this pawn take damage from an attack by a_Attacker.
Definition: Entity.cpp:272
float GetHealth(void) const
Returns the health of this entity.
Definition: Entity.h:367
bool IsMob(void) const
Definition: Entity.h:162
UInt32 GetCreatorUniqueID(void) const
Returns the unique ID of the entity who created this projectile May return an ID <0.
virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
Called by the physics blocktracer when the entity hits a solid block, the hit position and the face h...
virtual void OnHitEntity(cEntity &a_EntityHit, Vector3d a_HitPos)
Called by the physics blocktracer when the entity hits another entity.
cThrownSnowballEntity(cEntity *a_Creator, Vector3d a_Pos, Vector3d a_Speed)
virtual void OnHitEntity(cEntity &a_EntityHit, Vector3d a_HitPos) override
Called by the physics blocktracer when the entity hits another entity.
virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override
Called by the physics blocktracer when the entity hits a solid block, the hit position and the face h...
eMonsterType GetMobType(void) const
Definition: Monster.h:70
virtual void BroadcastEntityAnimation(const cEntity &a_Entity, EntityAnimation a_Animation, const cClientHandle *a_Exclude=nullptr) override