Cuberite
A lightweight, fast and extensible game server for Minecraft
FireChargeEntity.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 "FireChargeEntity.h"
4 #include "../World.h"
5 
6 
7 
8 
9 
11  super(pkFireCharge, a_Creator, a_Pos, 0.3125, 0.3125)
12 {
13  SetSpeed(a_Speed);
14  SetGravity(0);
15  SetAirDrag(0);
16 }
17 
18 
19 
20 
21 
23 {
24  if (m_World->GetBlock(a_Block) == E_BLOCK_AIR)
25  {
26  m_World->SetBlock(a_Block.x, a_Block.y, a_Block.z, E_BLOCK_FIRE, 1);
27  }
28 }
29 
30 
31 
32 
33 
35 {
36  Destroy();
37  Explode(a_HitPos.Floor());
38 }
39 
40 
41 
42 
43 
44 void cFireChargeEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
45 {
46  super::OnHitEntity(a_EntityHit, a_HitPos);
47 
48  Destroy();
49  Explode(a_HitPos.Floor());
50 
51  if (!a_EntityHit.IsFireproof())
52  {
53  // TODO Damage Entity with 5 damage(from https://minecraft.gamepedia.com/Blaze#Blaze_fireball)
54  a_EntityHit.StartBurning(5 * 20); // 5 seconds of burning
55  }
56 }
BLOCKTYPE GetBlock(Vector3i a_BlockPos)
Returns the block type at the specified position.
Definition: World.h:416
T x
Definition: Vector3.h:17
Vector3< int > Floor(void) const
Returns a new Vector3i with coords set to std::floor() of this vector&#39;s coords.
Definition: Vector3.h:172
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...
cWorld * m_World
Definition: Entity.h:620
virtual void OnHitEntity(cEntity &a_EntityHit, Vector3d a_HitPos) override
Called by the physics blocktracer when the entity hits another entity.
T y
Definition: Vector3.h:17
virtual void Destroy(bool a_ShouldBroadcast=true)
Destroys the entity and schedules it for memory freeing; if a_ShouldBroadcast is set to true...
Definition: Entity.cpp:219
T z
Definition: Vector3.h:17
void StartBurning(int a_TicksLeftBurning)
Puts the entity on fire for the specified amount of ticks.
Definition: Entity.cpp:1819
void Explode(Vector3i a_Block)
void SetGravity(float a_Gravity)
Definition: Entity.h:288
void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
Sets the speed of the entity, measured in m / sec.
Definition: Entity.cpp:2091
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc...
Definition: Defines.h:29
Definition: Entity.h:73
cFireChargeEntity(cEntity *a_Creator, Vector3d a_Pos, Vector3d a_Speed)
void SetAirDrag(float a_AirDrag)
Definition: Entity.h:292
virtual void OnHitEntity(cEntity &a_EntityHit, Vector3d a_HitPos)
Called by the physics blocktracer when the entity hits another entity.
virtual bool IsFireproof(void) const
Definition: Entity.h:422
void SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.
Definition: World.cpp:1873