From 0dd1cd750bb51403d85a226a97a5ad93eb99b144 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 15 Jun 2017 15:32:33 +0200 Subject: BlockEntities: Support cloning self. --- src/BlockEntities/BeaconEntity.cpp | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'src/BlockEntities/BeaconEntity.cpp') diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp index f7728600a..24de9e25c 100644 --- a/src/BlockEntities/BeaconEntity.cpp +++ b/src/BlockEntities/BeaconEntity.cpp @@ -11,13 +11,14 @@ -cBeaconEntity::cBeaconEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World): - super(E_BLOCK_BEACON, a_BlockX, a_BlockY, a_BlockZ, 1, 1, a_World), +cBeaconEntity::cBeaconEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World): + Super(a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, 1, 1, a_World), m_IsActive(false), m_BeaconLevel(0), m_PrimaryEffect(cEntityEffect::effNoEffect), m_SecondaryEffect(cEntityEffect::effNoEffect) { + ASSERT(a_BlockType == E_BLOCK_BEACON); UpdateBeacon(); } @@ -268,6 +269,30 @@ void cBeaconEntity::GiveEffects(void) +void cBeaconEntity::CopyFrom(const cBlockEntity & a_Src) +{ + Super::CopyFrom(a_Src); + auto & src = reinterpret_cast(a_Src); + m_BeaconLevel = src.m_BeaconLevel; + m_Contents.CopyFrom(src.m_Contents); + m_IsActive = src.m_IsActive; + m_PrimaryEffect = src.m_PrimaryEffect; + m_SecondaryEffect = src.m_SecondaryEffect; +} + + + + + +void cBeaconEntity::SendTo(cClientHandle & a_Client) +{ + a_Client.SendUpdateBlockEntity(*this); +} + + + + + bool cBeaconEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { // Update the beacon every 4 seconds @@ -306,12 +331,3 @@ bool cBeaconEntity::UsedBy(cPlayer * a_Player) - -void cBeaconEntity::SendTo(cClientHandle & a_Client) -{ - a_Client.SendUpdateBlockEntity(*this); -} - - - - -- cgit v1.2.3