diff options
author | Howaner <franzi.moos@googlemail.com> | 2014-07-30 21:59:35 +0200 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2014-07-30 21:59:35 +0200 |
commit | 89b1bbdc5fca5a51df1a5dd18ce91f27cb667c04 (patch) | |
tree | 7d22e13df345884785abbc167a4818235fd61e0a /src/BlockEntities/BeaconEntity.h | |
parent | Merged branch 'howaner/Options'. (diff) | |
download | cuberite-89b1bbdc5fca5a51df1a5dd18ce91f27cb667c04.tar cuberite-89b1bbdc5fca5a51df1a5dd18ce91f27cb667c04.tar.gz cuberite-89b1bbdc5fca5a51df1a5dd18ce91f27cb667c04.tar.bz2 cuberite-89b1bbdc5fca5a51df1a5dd18ce91f27cb667c04.tar.lz cuberite-89b1bbdc5fca5a51df1a5dd18ce91f27cb667c04.tar.xz cuberite-89b1bbdc5fca5a51df1a5dd18ce91f27cb667c04.tar.zst cuberite-89b1bbdc5fca5a51df1a5dd18ce91f27cb667c04.zip |
Diffstat (limited to 'src/BlockEntities/BeaconEntity.h')
-rw-r--r-- | src/BlockEntities/BeaconEntity.h | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/src/BlockEntities/BeaconEntity.h b/src/BlockEntities/BeaconEntity.h index ee1eda391..52111e82a 100644 --- a/src/BlockEntities/BeaconEntity.h +++ b/src/BlockEntities/BeaconEntity.h @@ -1,7 +1,7 @@ #pragma once -#include "BlockEntity.h" +#include "BlockEntityWithItems.h" @@ -17,26 +17,60 @@ namespace Json class cBeaconEntity : - public cBlockEntity + public cBlockEntityWithItems { - typedef cBlockEntity super; + typedef cBlockEntityWithItems 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); + + /** Is the beacon active? */ + bool IsActive(void) const { return m_IsActive; } + + /** Returns the beacon level. (0 - 4) */ + char GetBeaconLevel(void) const { return m_BeaconLevel; } + + char GetPrimaryPotion(void) const { return m_PrimaryPotion; } + char GetSecondaryPotion(void) const { return m_SecondaryPotion; } + + /** Select the primary potion. Returns false when the potion is invalid.*/ + bool SelectPrimaryPotion(cEntityEffect::eType a_Potion); + + /** Select the secondary potion. Returns false when the potion is invalid. */ + bool SelectSecondaryPotion(cEntityEffect::eType a_Potion); + + /** Calculate the amount of layers the pyramid below the beacon has. */ + char CalculatePyramidLevel(void); + + /** Is the beacon blocked by non-transparent blocks that are higher than the beacon? */ + bool IsBeaconBlocked(void); /** Returns true if the block is a diamond block, a golden block, an iron block or an emerald block. */ static bool IsMineralBlock(BLOCKTYPE a_BlockType); + + /** Returns true if the potion can be used. */ + static bool IsValidPotion(cEntityEffect::eType a_Potion, char a_BeaconLevel); + + /** Update the beacon. */ + void UpdateBeacon(void); + + /** Give the near-players the effects. */ + void GiveEffects(void); + + bool LoadFromJson(const Json::Value & a_Value); // 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; + virtual void SaveToJson(Json::Value& a_Value) override; + virtual void SendTo(cClientHandle & a_Client) override; + virtual bool Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void UsedBy(cPlayer * a_Player) override; + +protected: + bool m_IsActive; + char m_BeaconLevel; + + cEntityEffect::eType m_PrimaryPotion, m_SecondaryPotion; + } ; |