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.3125f, 0.3125f)
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, 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.wiki/w/Blaze#Blaze_fireball)
54  a_EntityHit.StartBurning(5 * 20); // 5 seconds of burning
55  }
56 }
@ E_BLOCK_AIR
Definition: BlockType.h:10
@ E_BLOCK_FIRE
Definition: BlockType.h:61
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
Definition: Defines.h:38
Definition: Entity.h:76
void SetGravity(float a_Gravity)
Definition: Entity.h:282
void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
Sets the speed of the entity, measured in m / sec.
Definition: Entity.cpp:2157
virtual bool IsFireproof(void) const
Definition: Entity.h:412
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 SetAirDrag(float a_AirDrag)
Definition: Entity.h:286
void StartBurning(int a_TicksLeftBurning)
Puts the entity on fire for the specified amount of ticks.
Definition: Entity.cpp:1908
cFireChargeEntity(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...
void Explode(Vector3i a_Block)
virtual void OnHitEntity(cEntity &a_EntityHit, Vector3d a_HitPos)
Called by the physics blocktracer when the entity hits another entity.
Vector3< int > Floor(void) const
Returns a new Vector3i with coords set to std::floor() of this vector's coords.
Definition: Vector3.h:177
BLOCKTYPE GetBlock(Vector3i a_BlockPos) const
Returns the block type at the specified position.
Definition: World.h:363
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:1743