summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities
diff options
context:
space:
mode:
authorSTRWarrior <niels.breuker@hotmail.nl>2014-04-12 00:01:15 +0200
committerSTRWarrior <niels.breuker@hotmail.nl>2014-04-12 00:01:15 +0200
commit875c2557c30aa5254c2ec3f4062ec463418c7d09 (patch)
tree29933f4e2c3d97efe5cbc2d5effaa07a643815d7 /src/BlockEntities
parentFixed issues with 64-bit MSVC compilation. (diff)
downloadcuberite-875c2557c30aa5254c2ec3f4062ec463418c7d09.tar
cuberite-875c2557c30aa5254c2ec3f4062ec463418c7d09.tar.gz
cuberite-875c2557c30aa5254c2ec3f4062ec463418c7d09.tar.bz2
cuberite-875c2557c30aa5254c2ec3f4062ec463418c7d09.tar.lz
cuberite-875c2557c30aa5254c2ec3f4062ec463418c7d09.tar.xz
cuberite-875c2557c30aa5254c2ec3f4062ec463418c7d09.tar.zst
cuberite-875c2557c30aa5254c2ec3f4062ec463418c7d09.zip
Diffstat (limited to 'src/BlockEntities')
-rw-r--r--src/BlockEntities/BeaconEntity.cpp111
-rw-r--r--src/BlockEntities/BeaconEntity.h40
-rw-r--r--src/BlockEntities/BlockEntity.cpp2
3 files changed, 153 insertions, 0 deletions
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
diff --git a/src/BlockEntities/BeaconEntity.h b/src/BlockEntities/BeaconEntity.h
new file mode 100644
index 000000000..1dfd745b2
--- /dev/null
+++ b/src/BlockEntities/BeaconEntity.h
@@ -0,0 +1,40 @@
+
+#pragma once
+
+#include "BlockEntity.h"
+
+
+
+
+
+namespace Json
+{
+ class Value;
+}
+
+
+
+
+
+class cBeaconEntity :
+ public cBlockEntity
+{
+ typedef cBlockEntity super;
+
+public:
+
+ // The initial constructor
+ cBeaconEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
+
+ // Returns the amount of layers the pyramid below the beacon has.
+ int GetPyramidLevel(void);
+
+ // Returns true if the block is a diamond block, an golden block, an iron block or an emerald block.
+ bool IsMineralBlock(BLOCKTYPE a_BlockType);
+
+ // cBlockEntity overrides:
+ virtual void SaveToJson(Json::Value& a_Value ) override;
+ virtual void SendTo(cClientHandle & a_Client) override;
+ virtual void UsedBy(cPlayer * a_Player) override;
+ virtual bool Tick(float a_Dt, cChunk & /* a_Chunk */) override;
+} ; \ No newline at end of file
diff --git a/src/BlockEntities/BlockEntity.cpp b/src/BlockEntities/BlockEntity.cpp
index b42318c2f..430f04551 100644
--- a/src/BlockEntities/BlockEntity.cpp
+++ b/src/BlockEntities/BlockEntity.cpp
@@ -4,6 +4,7 @@
// Implements the cBlockEntity class that is the common ancestor for all block entities
#include "Globals.h"
+#include "BeaconEntity.h"
#include "BlockEntity.h"
#include "ChestEntity.h"
#include "CommandBlockEntity.h"
@@ -26,6 +27,7 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE
{
switch (a_BlockType)
{
+ case E_BLOCK_BEACON: return new cBeaconEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_COMMAND_BLOCK: return new cCommandBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_DISPENSER: return new cDispenserEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);