diff options
author | Mattes D <github@xoft.cz> | 2014-01-18 20:39:42 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-01-18 20:39:42 +0100 |
commit | 36b9d4281978970e78af07a8a627213a974d2a7b (patch) | |
tree | 0db776a618aa6d195c5cec24acb8da3174896e68 /src/BlockEntities/CommandBlockEntity.h | |
parent | HTTP connections aren't kept alive unless explicitly enabled. (diff) | |
parent | Command block fixes (diff) | |
download | cuberite-36b9d4281978970e78af07a8a627213a974d2a7b.tar cuberite-36b9d4281978970e78af07a8a627213a974d2a7b.tar.gz cuberite-36b9d4281978970e78af07a8a627213a974d2a7b.tar.bz2 cuberite-36b9d4281978970e78af07a8a627213a974d2a7b.tar.lz cuberite-36b9d4281978970e78af07a8a627213a974d2a7b.tar.xz cuberite-36b9d4281978970e78af07a8a627213a974d2a7b.tar.zst cuberite-36b9d4281978970e78af07a8a627213a974d2a7b.zip |
Diffstat (limited to 'src/BlockEntities/CommandBlockEntity.h')
-rw-r--r-- | src/BlockEntities/CommandBlockEntity.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/BlockEntities/CommandBlockEntity.h b/src/BlockEntities/CommandBlockEntity.h new file mode 100644 index 000000000..12157670f --- /dev/null +++ b/src/BlockEntities/CommandBlockEntity.h @@ -0,0 +1,91 @@ + +// CommandBlockEntity.h + +// Declares the cCommandBlockEntity class representing a single command block in the world + + + + + +#pragma once + +#include "BlockEntity.h" + + + + + +namespace Json +{ + class Value; +} + + + + + +// tolua_begin + +class cCommandBlockEntity : + public cBlockEntity +{ + typedef cBlockEntity super; + +public: + + // tolua_end + + /// Creates a new empty command block entity + cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World); + + bool LoadFromJson( const Json::Value& a_Value ); + virtual void SaveToJson(Json::Value& a_Value ) override; + + virtual bool Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void SendTo(cClientHandle & a_Client) override; + virtual void UsedBy(cPlayer * a_Player) override; + + void SetLastOutput(const AString & a_LastOut); + + void SetResult(const NIBBLETYPE a_Result); + + // tolua_begin + + /// Sets the internal redstone power flag to "on" or "off", depending on the parameter. Calls Activate() if appropriate + void SetRedstonePower(bool a_IsPowered); + + /// Sets the command block to execute a command in the next tick + void Activate(void); + + /// Sets the command + void SetCommand(const AString & a_Cmd); + + /// Retrieves stored command + const AString & GetCommand(void) const; + + /// Retrieves the last line of output generated by the command block + const AString & GetLastOutput(void) const; + + /// Retrieves the result (signal strength) of the last operation + NIBBLETYPE GetResult(void) const; + + // tolua_end + +private: + + /// Executes the associated command + void Execute(); + + bool m_ShouldExecute; + bool m_IsPowered; + + AString m_Command; + + AString m_LastOutput; + + NIBBLETYPE m_Result; +} ; // tolua_export + + + + |