Cuberite
A lightweight, fast and extensible game server for Minecraft
BeaconEntity.h
Go to the documentation of this file.
1 
2 // BeaconEntity.h
3 
4 // Declares the cBeaconEntity class representing a single beacon in the world
5 
6 
7 
8 
9 
10 #pragma once
11 
12 #include "BlockEntityWithItems.h"
13 
14 
15 
16 
17 
18 // tolua_begin
21 {
22  // tolua_end
23 
25 
26 public: // tolua_export
27 
28  cBeaconEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World);
29 
30  // cBlockEntity overrides:
31  virtual void CopyFrom(const cBlockEntity & a_Src) override;
32  virtual void OnRemoveFromWorld() override;
33  virtual void SendTo(cClientHandle & a_Client) override;
34  virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
35  virtual bool UsedBy(cPlayer * a_Player) override;
36 
38  void SetBeaconLevel(char a_Level) { m_BeaconLevel = a_Level; }
39 
40  // tolua_begin
41 
43  bool IsActive(void) const { return m_IsActive; }
44 
46  char GetBeaconLevel(void) const { return m_BeaconLevel; }
47 
50 
53 
56 
58  char CalculatePyramidLevel(void);
59 
61  bool IsBeaconBlocked(void);
62 
64  void UpdateBeacon(void);
65 
67  void GiveEffects(void);
68 
70  static bool IsMineralBlock(BLOCKTYPE a_BlockType);
71 
73  static bool IsValidEffect(cEntityEffect::eType a_Effect, char a_BeaconLevel);
74 
75  // tolua_end
76 
77 protected:
78 
79  bool m_IsActive;
81 
83 } ; // tolua_export
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:44
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:41
void SetBeaconLevel(char a_Level)
Modify the beacon level.
Definition: BeaconEntity.h:38
bool SetPrimaryEffect(cEntityEffect::eType a_Effect)
Sets the primary effect.
void UpdateBeacon(void)
Update the beacon.
virtual void OnRemoveFromWorld() override
Called when the block entity object is removed from a world.
bool IsActive(void) const
Is the beacon active?
Definition: BeaconEntity.h:43
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking.
static bool IsMineralBlock(BLOCKTYPE a_BlockType)
Returns true if the block is a diamond block, a golden block, an iron block or an emerald block.
cEntityEffect::eType GetPrimaryEffect(void) const
Definition: BeaconEntity.h:48
virtual void SendTo(cClientHandle &a_Client) override
Sends the packet defining the block entity to the client specified.
cEntityEffect::eType m_PrimaryEffect
Definition: BeaconEntity.h:82
char CalculatePyramidLevel(void)
Calculate the amount of layers the pyramid below the beacon has.
static bool IsValidEffect(cEntityEffect::eType a_Effect, char a_BeaconLevel)
Returns true if the effect can be used.
void GiveEffects(void)
Give the near-players the effects.
virtual void CopyFrom(const cBlockEntity &a_Src) override
Copies all properties of a_Src into this entity, except for its m_World and location.
bool IsBeaconBlocked(void)
Is the beacon blocked by non-transparent blocks that are higher than the beacon?
cEntityEffect::eType m_SecondaryEffect
Definition: BeaconEntity.h:82
char GetBeaconLevel(void) const
Returns the beacon level.
Definition: BeaconEntity.h:46
char m_BeaconLevel
Definition: BeaconEntity.h:80
cEntityEffect::eType GetSecondaryEffect(void) const
Definition: BeaconEntity.h:49
virtual bool UsedBy(cPlayer *a_Player) override
Called when a player uses this entity; should open the UI window.
bool SetSecondaryEffect(cEntityEffect::eType a_Effect)
Sets the secondary effect.
cBeaconEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
cBlockEntityWithItems(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, int a_ItemGridWidth, int a_ItemGridHeight, cWorld *a_World)
Definition: Chunk.h:36
eType
All types of entity effects (numbers correspond to protocol / storage types)
Definition: EntityEffect.h:12
Definition: Player.h:29
Definition: World.h:53