summaryrefslogtreecommitdiffstats
path: root/src/Entities/EnderCrystal.cpp
blob: 269714b58d262f221ae1464b7b8746d61913751c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

#include "Globals.h"  // NOTE: MSVC stupidness requires this to be the same across all modules

#include "EnderCrystal.h"
#include "../ClientHandle.h"
#include "../Chunk.h"
#include "../World.h"





cEnderCrystal::cEnderCrystal(Vector3d a_Pos, bool a_ShowBottom):
	Super(etEnderCrystal, a_Pos, 1.0, 1.0),
	m_ShowBottom(a_ShowBottom)
{
	SetMaxHealth(5);
}





void cEnderCrystal::SpawnOn(cClientHandle & a_ClientHandle)
{
	a_ClientHandle.SendSpawnEntity(*this);
}





void cEnderCrystal::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
	UNUSED(a_Dt);
	// No further processing (physics e.t.c.) is needed
	if (m_World->GetDimension() == dimEnd)
	{
		m_World->SetBlock(POS_TOINT.addedY(1), E_BLOCK_FIRE, 0);
	}
}





void cEnderCrystal::KilledBy(TakeDamageInfo & a_TDI)
{
	Super::KilledBy(a_TDI);

	m_World->DoExplosionAt(6.0, GetPosX(), GetPosY(), GetPosZ(), true, esEnderCrystal, this);

	Destroy();

	m_World->SetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT, E_BLOCK_FIRE, 0);
}