2014-03-25 14:59:33 -04:00
|
|
|
|
|
|
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
|
|
|
|
|
|
|
#include "EnderCrystal.h"
|
2018-08-28 20:51:25 -04:00
|
|
|
#include "../ClientHandle.h"
|
2014-03-25 14:59:33 -04:00
|
|
|
#include "../Chunk.h"
|
2014-09-26 13:13:19 -04:00
|
|
|
#include "../World.h"
|
2014-03-25 14:59:33 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-06 10:00:59 -05:00
|
|
|
cEnderCrystal::cEnderCrystal(Vector3d a_Pos, bool a_ShowBottom) :
|
|
|
|
cEnderCrystal(a_Pos, {}, false, a_ShowBottom)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cEnderCrystal::cEnderCrystal(Vector3d a_Pos, Vector3i a_BeamTarget, bool a_DisplayBeam, bool a_ShowBottom) :
|
2021-04-06 11:09:16 -04:00
|
|
|
Super(etEnderCrystal, a_Pos, 2.0f, 2.0f),
|
2020-11-06 10:00:59 -05:00
|
|
|
m_BeamTarget(a_BeamTarget),
|
|
|
|
m_DisplayBeam(a_DisplayBeam),
|
2020-10-29 16:47:20 -04:00
|
|
|
m_ShowBottom(a_ShowBottom)
|
2014-03-25 14:59:33 -04:00
|
|
|
{
|
|
|
|
SetMaxHealth(5);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-06 10:00:59 -05:00
|
|
|
void cEnderCrystal::SetShowBottom(bool a_ShowBottom)
|
|
|
|
{
|
|
|
|
m_ShowBottom = a_ShowBottom;
|
|
|
|
m_World->BroadcastEntityMetadata(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cEnderCrystal::SetBeamTarget(Vector3i a_BeamTarget)
|
|
|
|
{
|
|
|
|
m_BeamTarget = a_BeamTarget;
|
|
|
|
m_World->BroadcastEntityMetadata(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cEnderCrystal::SetDisplayBeam(bool a_DisplayBeam)
|
|
|
|
{
|
|
|
|
m_DisplayBeam = a_DisplayBeam;
|
|
|
|
m_World->BroadcastEntityMetadata(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-25 14:59:33 -04:00
|
|
|
void cEnderCrystal::SpawnOn(cClientHandle & a_ClientHandle)
|
|
|
|
{
|
2020-04-20 15:46:04 -04:00
|
|
|
a_ClientHandle.SendSpawnEntity(*this);
|
2020-11-06 10:00:59 -05:00
|
|
|
a_ClientHandle.SendEntityMetadata(*this);
|
2014-03-25 14:59:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-01-11 16:12:26 -05:00
|
|
|
void cEnderCrystal::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
2014-03-25 14:59:33 -04:00
|
|
|
{
|
|
|
|
UNUSED(a_Dt);
|
2020-11-06 10:00:59 -05:00
|
|
|
if ((m_World->GetDimension() == dimEnd) && (m_World->GetBlock(POS_TOINT) != E_BLOCK_FIRE))
|
2020-10-29 16:47:20 -04:00
|
|
|
{
|
2020-11-06 10:00:59 -05:00
|
|
|
m_World->SetBlock(POS_TOINT, E_BLOCK_FIRE, 0);
|
2020-10-29 16:47:20 -04:00
|
|
|
}
|
2014-03-25 14:59:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-07-04 05:55:09 -04:00
|
|
|
void cEnderCrystal::KilledBy(TakeDamageInfo & a_TDI)
|
2014-03-25 14:59:33 -04:00
|
|
|
{
|
2020-04-13 12:38:06 -04:00
|
|
|
Super::KilledBy(a_TDI);
|
2014-03-25 14:59:33 -04:00
|
|
|
|
2021-01-22 12:06:26 -05:00
|
|
|
// Destroy first so the Explodinator doesn't find us (when iterating through entities):
|
2014-03-25 14:59:33 -04:00
|
|
|
Destroy();
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2021-04-06 11:09:16 -04:00
|
|
|
m_World->DoExplosionAt(6.0, GetPosX(), GetPosY() + GetHeight() / 2, GetPosZ(), true, esEnderCrystal, this);
|
2014-03-25 14:59:33 -04:00
|
|
|
|
2021-01-22 12:06:26 -05:00
|
|
|
const auto Position = GetPosition().Floor();
|
|
|
|
if (cChunkDef::IsValidHeight(Position.y))
|
|
|
|
{
|
|
|
|
m_World->SetBlock(Position, E_BLOCK_FIRE, 0);
|
|
|
|
}
|
|
|
|
}
|