Cuberite
A lightweight, fast and extensible game server for Minecraft
CommandBlockEntity.h
Go to the documentation of this file.
1 
2 // CommandBlockEntity.h
3 
4 // Declares the cCommandBlockEntity class representing a single command block in the world
5 
6 
7 
8 
9 
10 #pragma once
11 
12 #include "BlockEntity.h"
13 
14 
15 
16 
17 
18 // tolua_begin
19 
21  public cBlockEntity
22 {
23  // tolua_end
24 
26 
27 public: // tolua_export
28 
30  cCommandBlockEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World);
31 
32  // cBlockEntity overrides:
33  virtual void CopyFrom(const cBlockEntity & a_Src) override;
34  virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
35  virtual void SendTo(cClientHandle & a_Client) override;
36  virtual bool UsedBy(cPlayer * a_Player) override;
37 
38  void SetLastOutput(const AString & a_LastOut);
39 
40  void SetResult(const NIBBLETYPE a_Result);
41 
42  // tolua_begin
43 
45  void Activate(void);
46 
48  void SetCommand(const AString & a_Cmd);
49 
51  const AString & GetCommand(void) const;
52 
54  const AString & GetLastOutput(void) const;
55 
57  NIBBLETYPE GetResult(void) const;
58 
59  // tolua_end
60 
61 private:
62 
64  void Execute();
65 
67 
69 
71 
73 } ; // 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
std::string AString
Definition: StringUtils.h:11
cBlockEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
Definition: BlockEntity.cpp:32
cCommandBlockEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
Creates a new empty command block entity.
const AString & GetLastOutput(void) const
Retrieves the last line of output generated by the command block.
void Activate(void)
Sets the command block to execute a command in the next tick.
void Execute()
Executes the associated command.
virtual bool UsedBy(cPlayer *a_Player) override
Called when a player uses this entity; should open the UI window.
virtual void CopyFrom(const cBlockEntity &a_Src) override
Copies all properties of a_Src into this entity, except for its m_World and location.
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.
NIBBLETYPE GetResult(void) const
Retrieves the result (signal strength) of the last operation.
void SetLastOutput(const AString &a_LastOut)
void SetResult(const NIBBLETYPE a_Result)
void SetCommand(const AString &a_Cmd)
Sets the command.
const AString & GetCommand(void) const
Retrieves stored command.
virtual void SendTo(cClientHandle &a_Client) override
Sends the packet defining the block entity to the client specified.
Definition: Chunk.h:36
Definition: Player.h:29
Definition: World.h:53