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 
27 public: // tolua_export
28 
30 
31  cBeaconEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World);
32 
33  // cBlockEntity overrides:
34  virtual void CopyFrom(const cBlockEntity & a_Src) override;
35  virtual void SendTo(cClientHandle & a_Client) override;
36  virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
37  virtual bool UsedBy(cPlayer * a_Player) override;
38 
40  void SetBeaconLevel(char a_Level) { m_BeaconLevel = a_Level; }
41 
42  // tolua_begin
43 
45  bool IsActive(void) const { return m_IsActive; }
46 
48  char GetBeaconLevel(void) const { return m_BeaconLevel; }
49 
52 
55 
58 
60  char CalculatePyramidLevel(void);
61 
63  bool IsBeaconBlocked(void);
64 
66  void UpdateBeacon(void);
67 
69  void GiveEffects(void);
70 
72  static bool IsMineralBlock(BLOCKTYPE a_BlockType);
73 
75  static bool IsValidEffect(cEntityEffect::eType a_Effect, char a_BeaconLevel);
76 
77  // tolua_end
78 
79 protected:
80  bool m_IsActive;
82 
84 } ; // tolua_export
85 
86 
87 
88 
bool IsBeaconBlocked(void)
Is the beacon blocked by non-transparent blocks that are higher than the beacon?
eType
All types of entity effects (numbers correspond to protocol / storage types)
Definition: EntityEffect.h:11
Definition: FastNBT.h:131
void SetBeaconLevel(char a_Level)
Modify the beacon level.
Definition: BeaconEntity.h:40
cBlockEntityWithItems(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, int a_ItemGridWidth, int a_ItemGridHeight, cWorld *a_World)
char m_BeaconLevel
Definition: BeaconEntity.h:81
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...
void GiveEffects(void)
Give the near-players the effects.
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
cEntityEffect::eType GetSecondaryEffect(void) const
Definition: BeaconEntity.h:51
cEntityEffect::eType m_SecondaryEffect
Definition: BeaconEntity.h:83
Definition: Player.h:27
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 m_PrimaryEffect
Definition: BeaconEntity.h:83
char CalculatePyramidLevel(void)
Calculate the amount of layers the pyramid below the beacon has.
virtual void CopyFrom(const cBlockEntity &a_Src) override
Copies all properties of a_Src into this entity, except for its m_World and location.
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:45
void UpdateBeacon(void)
Update the beacon.
bool IsActive(void) const
Is the beacon active?
Definition: BeaconEntity.h:45
virtual bool UsedBy(cPlayer *a_Player) override
Called when a player uses this entity; should open the UI window.
Definition: Chunk.h:49
char GetBeaconLevel(void) const
Returns the beacon level.
Definition: BeaconEntity.h:48
Definition: World.h:65
static bool IsValidEffect(cEntityEffect::eType a_Effect, char a_BeaconLevel)
Returns true if the effect can be used.
virtual void SendTo(cClientHandle &a_Client) override
Sends the packet defining the block entity to the client specified.
#define BLOCKENTITY_PROTODEF(classname)
Place this macro in the declaration of each cBlockEntity descendant.
Definition: BlockEntity.h:9
bool SetSecondaryEffect(cEntityEffect::eType a_Effect)
Sets the secondary effect.
bool SetPrimaryEffect(cEntityEffect::eType a_Effect)
Sets the primary effect.
cEntityEffect::eType GetPrimaryEffect(void) const
Definition: BeaconEntity.h:50