From 9a9b51a5134d8afd8f089d247c59668bd7da695d Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 18 Jan 2014 15:16:47 +0200 Subject: Basic command block implementation --- src/BlockEntities/BlockEntity.cpp | 24 +++-- src/BlockEntities/CommandBlockEntity.cpp | 173 +++++++++++++++++++++++++++++++ src/BlockEntities/CommandBlockEntity.h | 85 +++++++++++++++ 3 files changed, 271 insertions(+), 11 deletions(-) create mode 100644 src/BlockEntities/CommandBlockEntity.cpp create mode 100644 src/BlockEntities/CommandBlockEntity.h (limited to 'src/BlockEntities') diff --git a/src/BlockEntities/BlockEntity.cpp b/src/BlockEntities/BlockEntity.cpp index 5d7e4a37a..97b5c1a66 100644 --- a/src/BlockEntities/BlockEntity.cpp +++ b/src/BlockEntities/BlockEntity.cpp @@ -6,6 +6,7 @@ #include "Globals.h" #include "BlockEntity.h" #include "ChestEntity.h" +#include "CommandBlockEntity.h" #include "DispenserEntity.h" #include "DropperEntity.h" #include "EnderChestEntity.h" @@ -23,17 +24,18 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE { switch (a_BlockType) { - case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); - case E_BLOCK_DISPENSER: return new cDispenserEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); - case E_BLOCK_DROPPER: return new cDropperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); - case E_BLOCK_ENDER_CHEST: return new cEnderChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); - case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World); - case E_BLOCK_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World); - case E_BLOCK_HOPPER: return new cHopperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); - case E_BLOCK_SIGN_POST: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World); - case E_BLOCK_WALLSIGN: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World); - case E_BLOCK_NOTE_BLOCK: return new cNoteEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); - case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); + case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); + case E_BLOCK_COMMAND_BLOCK: return new cCommandBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_World); + case E_BLOCK_DISPENSER: return new cDispenserEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); + case E_BLOCK_DROPPER: return new cDropperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); + case E_BLOCK_ENDER_CHEST: return new cEnderChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); + case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World); + case E_BLOCK_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World); + case E_BLOCK_HOPPER: return new cHopperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); + case E_BLOCK_SIGN_POST: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World); + case E_BLOCK_WALLSIGN: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World); + case E_BLOCK_NOTE_BLOCK: return new cNoteEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); + case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockX, a_BlockY, a_BlockZ, a_World); } LOGD("%s: Requesting creation of an unknown block entity - block type %d (%s)", __FUNCTION__, a_BlockType, ItemTypeToString(a_BlockType).c_str() diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp new file mode 100644 index 000000000..6e371e0fe --- /dev/null +++ b/src/BlockEntities/CommandBlockEntity.cpp @@ -0,0 +1,173 @@ + +// CommandBlockEntity.cpp + +// Implements the cCommandBlockEntity class representing a single command block in the world + +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules +#include "json/json.h" +#include "CommandBlockEntity.h" +#include "../Entities/Player.h" + + + + + +cCommandBlockEntity::cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World) : + super(E_BLOCK_COMMAND_BLOCK, a_X, a_Y, a_Z, a_World), + m_ShouldExecute(false), + m_IsPowered(false) +{ + SetBlockEntity(this); // cBlockEntityWindowOwner +} + + + + + + +cCommandBlockEntity::~cCommandBlockEntity() +{ + // Tell window its owner is destroyed + cWindow * Window = GetWindow(); + if (Window != NULL) + { + Window->OwnerDestroyed(); + } +} + + + + + + +void cCommandBlockEntity::UsedBy(cPlayer * a_Player) +{ + cWindow * Window = GetWindow(); + if (Window == NULL) + { + //OpenWindow(new cDropSpenserWindow(m_PosX, m_PosY, m_PosZ, this)); + Window = GetWindow(); + } + + if (Window != NULL) + { + if (a_Player->GetWindow() != Window) + { + a_Player->OpenWindow(Window); + } + } +} + + + + + +void cCommandBlockEntity::SetCommand(const AString & a_Cmd) +{ + m_Command = a_Cmd;LOGD("Hrey %s", a_Cmd.c_str()); +} + + + + + +const AString & cCommandBlockEntity::GetCommand(void) const +{ + return m_Command; +} + + + + + +const AString & cCommandBlockEntity::GetLastOutput(void) const +{ + return m_LastOutput; +} + + + + + +void cCommandBlockEntity::Activate(void) +{ + m_ShouldExecute = true; +} + + + + + +void cCommandBlockEntity::SetRedstonePower(bool a_IsPowered) +{ + if (a_IsPowered && !m_IsPowered) + { + Activate(); + } + m_IsPowered = a_IsPowered; +} + + + + + +bool cCommandBlockEntity::Tick(float a_Dt, cChunk & a_Chunk) +{ + if (!m_ShouldExecute) + { + return false; + } + + m_ShouldExecute = false; + Execute(); + return true; +} + + + + + +void cCommandBlockEntity::SendTo(cClientHandle & a_Client) +{ + // Nothing needs to be sent + UNUSED(a_Client); +} + + + + + +bool cCommandBlockEntity::LoadFromJson(const Json::Value & a_Value) +{ + m_Command = a_Value.get("Command", "").asString(); + + m_LastOutput = a_Value.get("LastOutput", "").asString(); + + return true; +} + + + + + +void cCommandBlockEntity::SaveToJson(Json::Value & a_Value) +{ + a_Value["Command"] = m_Command; + + a_Value["LastOutput"] = m_LastOutput; +} + + + + + +void cCommandBlockEntity::Execute() +{ + // TODO: Parse arguments and dispatch command + LOGD("Command: %s", m_Command.c_str()); + m_LastOutput = ""; +} + + + + 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 + + + + -- cgit v1.2.3 From be5299350a3b808ade39df7e9654eda47732e96e Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 18 Jan 2014 15:40:47 +0200 Subject: Command block (de)serialization --- src/BlockEntities/CommandBlockEntity.cpp | 32 +++++++++++++++++++++++++++++++- src/BlockEntities/CommandBlockEntity.h | 13 +++++++++++-- 2 files changed, 42 insertions(+), 3 deletions(-) (limited to 'src/BlockEntities') diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp index 6e371e0fe..88e55dece 100644 --- a/src/BlockEntities/CommandBlockEntity.cpp +++ b/src/BlockEntities/CommandBlockEntity.cpp @@ -45,7 +45,7 @@ void cCommandBlockEntity::UsedBy(cPlayer * a_Player) cWindow * Window = GetWindow(); if (Window == NULL) { - //OpenWindow(new cDropSpenserWindow(m_PosX, m_PosY, m_PosZ, this)); + //OpenWindow(new cDropSpenserWindow(m_PosX, m_PosY, m_PosZ, this)); FIXME Window = GetWindow(); } @@ -71,6 +71,24 @@ void cCommandBlockEntity::SetCommand(const AString & a_Cmd) +void cCommandBlockEntity::SetLastOutput(const AString & a_LastOut) +{ + m_LastOutput = a_LastOut; +} + + + + + +void cCommandBlockEntity::SetResult(const NIBBLETYPE a_Result) +{ + m_Result = a_Result; +} + + + + + const AString & cCommandBlockEntity::GetCommand(void) const { return m_Command; @@ -89,6 +107,15 @@ const AString & cCommandBlockEntity::GetLastOutput(void) const +NIBBLETYPE cCommandBlockEntity::GetResult(void) const +{ + return m_Result; +} + + + + + void cCommandBlockEntity::Activate(void) { m_ShouldExecute = true; @@ -164,8 +191,11 @@ void cCommandBlockEntity::SaveToJson(Json::Value & a_Value) void cCommandBlockEntity::Execute() { // TODO: Parse arguments and dispatch command + LOGD("Command: %s", m_Command.c_str()); + m_LastOutput = ""; + m_Result = 0; } diff --git a/src/BlockEntities/CommandBlockEntity.h b/src/BlockEntities/CommandBlockEntity.h index 266a3c33d..c4529a1e6 100644 --- a/src/BlockEntities/CommandBlockEntity.h +++ b/src/BlockEntities/CommandBlockEntity.h @@ -48,6 +48,10 @@ public: 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 @@ -64,6 +68,9 @@ public: /// 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 @@ -75,9 +82,11 @@ private: bool m_ShouldExecute; bool m_IsPowered; - AString m_Command; + AString m_Command; + + AString m_LastOutput; - AString m_LastOutput; + NIBBLETYPE m_Result; } ; // tolua_export -- cgit v1.2.3 From 1ad6469a180dfe6932c756fe3c99bcada3ee0b7e Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 18 Jan 2014 16:59:33 +0200 Subject: Command blocks: Execute() --- src/BlockEntities/CommandBlockEntity.cpp | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'src/BlockEntities') diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp index 88e55dece..e70e259aa 100644 --- a/src/BlockEntities/CommandBlockEntity.cpp +++ b/src/BlockEntities/CommandBlockEntity.cpp @@ -8,6 +8,10 @@ #include "CommandBlockEntity.h" #include "../Entities/Player.h" +#include "CommandOutput.h" +#include "Root.h" +#include "Server.h" // ExecuteConsoleCommand() + @@ -45,7 +49,8 @@ void cCommandBlockEntity::UsedBy(cPlayer * a_Player) cWindow * Window = GetWindow(); if (Window == NULL) { - //OpenWindow(new cDropSpenserWindow(m_PosX, m_PosY, m_PosZ, this)); FIXME + // TODO 2014-01-18 xdot: Open the appropriate window. + // OpenWindow(new cCommandBlockWindow(m_PosX, m_PosY, m_PosZ, this)); Window = GetWindow(); } @@ -64,7 +69,7 @@ void cCommandBlockEntity::UsedBy(cPlayer * a_Player) void cCommandBlockEntity::SetCommand(const AString & a_Cmd) { - m_Command = a_Cmd;LOGD("Hrey %s", a_Cmd.c_str()); + m_Command = a_Cmd; } @@ -190,11 +195,28 @@ void cCommandBlockEntity::SaveToJson(Json::Value & a_Value) void cCommandBlockEntity::Execute() { - // TODO: Parse arguments and dispatch command + class CommandBlockOutCb : + public cCommandOutputCallback + { + cCommandBlockEntity* m_CmdBlock; + + public: + CommandBlockOutCb(cCommandBlockEntity* a_CmdBlock) : m_CmdBlock(a_CmdBlock) {} + + virtual void Out(const AString & a_Text) + { + ASSERT(m_CmdBlock != NULL); + + // Overwrite field + m_CmdBlock->SetLastOutput(a_Text); + } + } CmdBlockOutCb(this); + + cServer* Server = cRoot::Get()->GetServer(); - LOGD("Command: %s", m_Command.c_str()); + Server->ExecuteConsoleCommand(m_Command, CmdBlockOutCb); - m_LastOutput = ""; + // TODO 2014-01-18 xdot: Update the signal strength. m_Result = 0; } -- cgit v1.2.3 From 02c9aa2b1e86974df4ef8ea152465719169bdac5 Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 18 Jan 2014 19:58:46 +0200 Subject: Parse the MC|AdvCdm plugin message --- src/BlockEntities/CommandBlockEntity.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/BlockEntities') diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp index e70e259aa..c29e3dff8 100644 --- a/src/BlockEntities/CommandBlockEntity.cpp +++ b/src/BlockEntities/CommandBlockEntity.cpp @@ -212,6 +212,8 @@ void cCommandBlockEntity::Execute() } } CmdBlockOutCb(this); + LOGD("cCommandBlockEntity: Executing command %s", m_Command.c_str()); + cServer* Server = cRoot::Get()->GetServer(); Server->ExecuteConsoleCommand(m_Command, CmdBlockOutCb); -- cgit v1.2.3 From a037172465932de7d0d7d725c3c8ec5b2fa44029 Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 18 Jan 2014 21:27:54 +0200 Subject: Command block fixes --- src/BlockEntities/CommandBlockEntity.cpp | 36 +++----------------------------- src/BlockEntities/CommandBlockEntity.h | 7 ++----- 2 files changed, 5 insertions(+), 38 deletions(-) (limited to 'src/BlockEntities') diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp index c29e3dff8..543d47b7a 100644 --- a/src/BlockEntities/CommandBlockEntity.cpp +++ b/src/BlockEntities/CommandBlockEntity.cpp @@ -20,24 +20,7 @@ cCommandBlockEntity::cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_W super(E_BLOCK_COMMAND_BLOCK, a_X, a_Y, a_Z, a_World), m_ShouldExecute(false), m_IsPowered(false) -{ - SetBlockEntity(this); // cBlockEntityWindowOwner -} - - - - - - -cCommandBlockEntity::~cCommandBlockEntity() -{ - // Tell window its owner is destroyed - cWindow * Window = GetWindow(); - if (Window != NULL) - { - Window->OwnerDestroyed(); - } -} +{} @@ -46,21 +29,8 @@ cCommandBlockEntity::~cCommandBlockEntity() void cCommandBlockEntity::UsedBy(cPlayer * a_Player) { - cWindow * Window = GetWindow(); - if (Window == NULL) - { - // TODO 2014-01-18 xdot: Open the appropriate window. - // OpenWindow(new cCommandBlockWindow(m_PosX, m_PosY, m_PosZ, this)); - Window = GetWindow(); - } - - if (Window != NULL) - { - if (a_Player->GetWindow() != Window) - { - a_Player->OpenWindow(Window); - } - } + // Nothing to do + UNUSED(a_Player); } diff --git a/src/BlockEntities/CommandBlockEntity.h b/src/BlockEntities/CommandBlockEntity.h index c4529a1e6..12157670f 100644 --- a/src/BlockEntities/CommandBlockEntity.h +++ b/src/BlockEntities/CommandBlockEntity.h @@ -9,8 +9,7 @@ #pragma once -#include "BlockEntityWithItems.h" -#include "../UI/WindowOwner.h" +#include "BlockEntity.h" @@ -28,8 +27,7 @@ namespace Json // tolua_begin class cCommandBlockEntity : - public cBlockEntity, - public cBlockEntityWindowOwner + public cBlockEntity { typedef cBlockEntity super; @@ -39,7 +37,6 @@ public: /// 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; -- cgit v1.2.3 From f8c8dcc7f36366dc6b59e6741d466e739322d5d1 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 19 Jan 2014 00:54:38 +0000 Subject: Improved command blocks * Their command and previous output are displayed on the client * They have a BlockHandler implementation, so you can't place blocks on them anymore + As a side effect, implemented UpdateBlockEntity --- src/BlockEntities/CommandBlockEntity.cpp | 42 ++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'src/BlockEntities') diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp index 543d47b7a..6e5c8087e 100644 --- a/src/BlockEntities/CommandBlockEntity.cpp +++ b/src/BlockEntities/CommandBlockEntity.cpp @@ -7,10 +7,11 @@ #include "json/json.h" #include "CommandBlockEntity.h" #include "../Entities/Player.h" +#include "../WorldStorage/FastNBT.h" -#include "CommandOutput.h" -#include "Root.h" -#include "Server.h" // ExecuteConsoleCommand() +#include "../CommandOutput.h" +#include "../Root.h" +#include "../Server.h" // ExecuteConsoleCommand() @@ -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()); } @@ -131,8 +141,30 @@ bool cCommandBlockEntity::Tick(float a_Dt, cChunk & a_Chunk) void cCommandBlockEntity::SendTo(cClientHandle & a_Client) { - // Nothing needs to be sent - UNUSED(a_Client); + cFastNBTWriter Writer; + Writer.AddByte("TrackOutput", 1); // Neither I nor the MC wiki has any idea about this + Writer.AddInt("SuccessCount", GetResult()); + Writer.AddInt("x", GetPosX()); + Writer.AddInt("y", GetPosY()); + Writer.AddInt("z", GetPosZ()); + Writer.AddString("Command", GetCommand().c_str()); + // You can set custom names for windows in Vanilla + // For a command block, this would be the 'name' prepended to anything it outputs into global chat + // MCS doesn't have this, so just leave it @ '@'. (geddit?) + Writer.AddString("CustomName", "@"); + Writer.AddString("id", "Control"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though + + if (!GetLastOutput().empty()) + { + AString Output; + Printf(Output, "{\"text\":\"%s\"}", GetLastOutput().c_str()); + + Writer.AddString("LastOutput", Output.c_str()); + } + + Writer.Finish(); + + a_Client.SendUpdateBlockEntity(GetPosX(), GetPosY(), GetPosZ(), 2, Writer); } -- cgit v1.2.3 From 1af89a8b50a382ef0f5c137a84ab2816c45cc73c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 19 Jan 2014 13:25:35 +0000 Subject: Changed SendBlockEntity format slightly * Writing NBT is now in Protocol, not BlockEntity files * Fixed a last output bug --- src/BlockEntities/CommandBlockEntity.cpp | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) (limited to 'src/BlockEntities') diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp index 6e5c8087e..38737d619 100644 --- a/src/BlockEntities/CommandBlockEntity.cpp +++ b/src/BlockEntities/CommandBlockEntity.cpp @@ -58,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; } @@ -141,30 +142,7 @@ bool cCommandBlockEntity::Tick(float a_Dt, cChunk & a_Chunk) void cCommandBlockEntity::SendTo(cClientHandle & a_Client) { - cFastNBTWriter Writer; - Writer.AddByte("TrackOutput", 1); // Neither I nor the MC wiki has any idea about this - Writer.AddInt("SuccessCount", GetResult()); - Writer.AddInt("x", GetPosX()); - Writer.AddInt("y", GetPosY()); - Writer.AddInt("z", GetPosZ()); - Writer.AddString("Command", GetCommand().c_str()); - // You can set custom names for windows in Vanilla - // For a command block, this would be the 'name' prepended to anything it outputs into global chat - // MCS doesn't have this, so just leave it @ '@'. (geddit?) - Writer.AddString("CustomName", "@"); - Writer.AddString("id", "Control"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though - - if (!GetLastOutput().empty()) - { - AString Output; - Printf(Output, "{\"text\":\"%s\"}", GetLastOutput().c_str()); - - Writer.AddString("LastOutput", Output.c_str()); - } - - Writer.Finish(); - - a_Client.SendUpdateBlockEntity(GetPosX(), GetPosY(), GetPosZ(), 2, Writer); + a_Client.SendUpdateBlockEntity(GetPosX(), GetPosY(), GetPosZ(), 2, *this); } -- cgit v1.2.3 From e4c3d799ffddb93c658062f9663ec027fc2f1d5a Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 19 Jan 2014 19:42:25 +0000 Subject: Removed unneeded paramters --- src/BlockEntities/CommandBlockEntity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/BlockEntities') diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp index 38737d619..7e9015d33 100644 --- a/src/BlockEntities/CommandBlockEntity.cpp +++ b/src/BlockEntities/CommandBlockEntity.cpp @@ -142,7 +142,7 @@ bool cCommandBlockEntity::Tick(float a_Dt, cChunk & a_Chunk) void cCommandBlockEntity::SendTo(cClientHandle & a_Client) { - a_Client.SendUpdateBlockEntity(GetPosX(), GetPosY(), GetPosZ(), 2, *this); + a_Client.SendUpdateBlockEntity(*this); } -- cgit v1.2.3