From 875c2557c30aa5254c2ec3f4062ec463418c7d09 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 12 Apr 2014 00:01:15 +0200 Subject: Implemented the skeleton code for the beacon. There is no handling for the GUI. It can now check how big the pyramid is under the beacon. --- src/BlockEntities/BeaconEntity.cpp | 111 +++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 src/BlockEntities/BeaconEntity.cpp (limited to 'src/BlockEntities/BeaconEntity.cpp') diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp new file mode 100644 index 000000000..e5e890dbc --- /dev/null +++ b/src/BlockEntities/BeaconEntity.cpp @@ -0,0 +1,111 @@ + +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "BeaconEntity.h" +#include "../BlockArea.h" + + + + + +cBeaconEntity::cBeaconEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) : + super(E_BLOCK_BEACON, a_BlockX, a_BlockY, a_BlockZ, a_World) +{ +} + + + + + +int cBeaconEntity::GetPyramidLevel() +{ + cBlockArea Area; + Area.Read( + m_World, + GetPosX() - 4, + GetPosX() + 4, + GetPosY() - 5, + GetPosY() - 1, + GetPosZ() - 4, + GetPosZ() + 4 + ); + + int Layer = 1; + int MiddleXZ = 4; + + for (int Y = Area.GetSizeY() - 1; Y > 0; Y--) + { + bool FullLayer = true; + for (int X = MiddleXZ - Layer; X <= (MiddleXZ + Layer); X++) + { + for (int Z = MiddleXZ - Layer; Z <= (MiddleXZ + Layer); Z++) + { + if (!IsMineralBlock(Area.GetRelBlockType(X, Y, Z))) + { + FullLayer = false; + } + } + } + if (!FullLayer) + { + break; + } + else + { + Layer++; + } + } + + return Layer; +} + + + + + +bool cBeaconEntity::IsMineralBlock(BLOCKTYPE a_BlockType) +{ + switch(a_BlockType) + { + case E_BLOCK_DIAMOND_BLOCK: + case E_BLOCK_GOLD_BLOCK: + case E_BLOCK_IRON_BLOCK: + case E_BLOCK_EMERALD_BLOCK: + { + return true; + } + } + return false; +} + + + + + +bool cBeaconEntity::Tick(float a_Dt, cChunk & a_Chunk) +{ + return false; +} + + + + + +void cBeaconEntity::SaveToJson(Json::Value& a_Value) +{ +} + + + + +void cBeaconEntity::SendTo(cClientHandle & a_Client) +{ +} + + + + + +void cBeaconEntity::UsedBy(cPlayer * a_Player) +{ +} \ No newline at end of file -- cgit v1.2.3