diff options
author | andrew <xdotftw@gmail.com> | 2014-01-18 14:16:47 +0100 |
---|---|---|
committer | andrew <xdotftw@gmail.com> | 2014-01-18 14:16:47 +0100 |
commit | 9a9b51a5134d8afd8f089d247c59668bd7da695d (patch) | |
tree | 74be5c51628307a8ddf8ce39a0236dfb511c7941 /src/BlockEntities/CommandBlockEntity.h | |
parent | Merge pull request #552 from worktycho/c++11 (diff) | |
download | cuberite-9a9b51a5134d8afd8f089d247c59668bd7da695d.tar cuberite-9a9b51a5134d8afd8f089d247c59668bd7da695d.tar.gz cuberite-9a9b51a5134d8afd8f089d247c59668bd7da695d.tar.bz2 cuberite-9a9b51a5134d8afd8f089d247c59668bd7da695d.tar.lz cuberite-9a9b51a5134d8afd8f089d247c59668bd7da695d.tar.xz cuberite-9a9b51a5134d8afd8f089d247c59668bd7da695d.tar.zst cuberite-9a9b51a5134d8afd8f089d247c59668bd7da695d.zip |
Diffstat (limited to '')
-rw-r--r-- | src/BlockEntities/CommandBlockEntity.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/BlockEntities/CommandBlockEntity.h b/src/BlockEntities/CommandBlockEntity.h new file mode 100644 index 000000000..266a3c33d --- /dev/null +++ b/src/BlockEntities/CommandBlockEntity.h @@ -0,0 +1,85 @@ + +// CommandBlockEntity.h + +// Declares the cCommandBlockEntity class representing a single command block in the world + + + + + +#pragma once + +#include "BlockEntityWithItems.h" +#include "../UI/WindowOwner.h" + + + + + +namespace Json +{ + class Value; +} + + + + + +// tolua_begin + +class cCommandBlockEntity : + public cBlockEntity, + public cBlockEntityWindowOwner +{ + 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); + virtual ~cCommandBlockEntity(); + + 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; + + // 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; + + // tolua_end + +private: + + /// Executes the associated command + void Execute(); + + bool m_ShouldExecute; + bool m_IsPowered; + + AString m_Command; + + AString m_LastOutput; +} ; // tolua_export + + + + |