summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities/CommandBlockEntity.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/BlockEntities/CommandBlockEntity.cpp')
-rw-r--r--src/BlockEntities/CommandBlockEntity.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp
index ca617b04d..7e9015d33 100644
--- a/src/BlockEntities/CommandBlockEntity.cpp
+++ b/src/BlockEntities/CommandBlockEntity.cpp
@@ -7,6 +7,7 @@
#include "json/json.h"
#include "CommandBlockEntity.h"
#include "../Entities/Player.h"
+#include "../WorldStorage/FastNBT.h"
#include "../CommandOutput.h"
#include "../Root.h"
@@ -40,6 +41,15 @@ void cCommandBlockEntity::UsedBy(cPlayer * a_Player)
void cCommandBlockEntity::SetCommand(const AString & a_Cmd)
{
m_Command = a_Cmd;
+
+ /*
+ Vanilla requires that the server send a Block Entity Update after a command has been set
+ Therefore, command blocks don't support on-the-fly (when window is open) updating of a command and therefore...
+ ...the following code can't be put in UsedBy just before the window opens
+
+ Just documenting my experience in getting this to work :P
+ */
+ m_World->BroadcastBlockEntity(GetPosX(), GetPosY(), GetPosZ());
}
@@ -48,6 +58,7 @@ void cCommandBlockEntity::SetCommand(const AString & a_Cmd)
void cCommandBlockEntity::SetLastOutput(const AString & a_LastOut)
{
+ m_World->BroadcastBlockEntity(GetPosX(), GetPosY(), GetPosZ());
m_LastOutput = a_LastOut;
}
@@ -131,8 +142,7 @@ bool cCommandBlockEntity::Tick(float a_Dt, cChunk & a_Chunk)
void cCommandBlockEntity::SendTo(cClientHandle & a_Client)
{
- // Nothing needs to be sent
- UNUSED(a_Client);
+ a_Client.SendUpdateBlockEntity(*this);
}