Cuberite
A lightweight, fast and extensible game server for Minecraft
EnderCrystal.cpp
Go to the documentation of this file.
1 
2 #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
3 
4 #include "EnderCrystal.h"
5 #include "../ClientHandle.h"
6 #include "../Chunk.h"
7 #include "../World.h"
8 
9 
10 
11 
12 
14  super(etEnderCrystal, a_Pos, 1.0, 1.0)
15 {
16  SetMaxHealth(5);
17 }
18 
19 
20 
21 
22 
23 void cEnderCrystal::SpawnOn(cClientHandle & a_ClientHandle)
24 {
25  a_ClientHandle.SendSpawnObject(*this, 51, 0, static_cast<Byte>(GetYaw()), static_cast<Byte>(GetPitch()));
26 }
27 
28 
29 
30 
31 
32 void cEnderCrystal::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
33 {
34  UNUSED(a_Dt);
35  // No further processing (physics e.t.c.) is needed
36 }
37 
38 
39 
40 
41 
43 {
44  super::KilledBy(a_TDI);
45 
46  m_World->DoExplosionAt(6.0, GetPosX(), GetPosY(), GetPosZ(), true, esEnderCrystal, this);
47 
48  Destroy();
49 
52 }
53 
54 
55 
56 
double GetPosY(void) const
Definition: Entity.h:207
double GetPitch(void) const
Definition: Entity.h:210
double GetPosX(void) const
Definition: Entity.h:206
virtual void KilledBy(TakeDamageInfo &a_TDI)
Called when the health drops below zero.
Definition: Entity.cpp:791
cWorld * m_World
Definition: Entity.h:620
virtual void KilledBy(TakeDamageInfo &a_TDI) override
Called when the health drops below zero.
void SendSpawnObject(const cEntity &a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch)
Definition: Chunk.h:49
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
void SetMaxHealth(float a_MaxHealth)
Sets the maximum value for the health.
Definition: Entity.cpp:1798
virtual void SpawnOn(cClientHandle &a_ClientHandle) override
Descendants override this function to send a command to the specified client to spawn the entity on t...
#define POSX_TOINT
Definition: Entity.h:29
#define POSY_TOINT
Definition: Entity.h:30
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
#define UNUSED
Definition: Globals.h:152
double GetYaw(void) const
Definition: Entity.h:209
cEnderCrystal(Vector3d a_Pos)
virtual void DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, bool a_CanCauseFire, eExplosionSource a_Source, void *a_SourceData) override
Does an explosion with the specified strength at the specified coordinates.
Definition: World.cpp:1399
Definition: Entity.h:73
double GetPosZ(void) const
Definition: Entity.h:208
#define POSZ_TOINT
Definition: Entity.h:31
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