Parse the MC|AdvCdm plugin message
This commit is contained in:
parent
1ad6469a18
commit
02c9aa2b1e
|
@ -212,6 +212,8 @@ void cCommandBlockEntity::Execute()
|
||||||
}
|
}
|
||||||
} CmdBlockOutCb(this);
|
} CmdBlockOutCb(this);
|
||||||
|
|
||||||
|
LOGD("cCommandBlockEntity: Executing command %s", m_Command.c_str());
|
||||||
|
|
||||||
cServer* Server = cRoot::Get()->GetServer();
|
cServer* Server = cRoot::Get()->GetServer();
|
||||||
|
|
||||||
Server->ExecuteConsoleCommand(m_Command, CmdBlockOutCb);
|
Server->ExecuteConsoleCommand(m_Command, CmdBlockOutCb);
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "Entities/Player.h"
|
#include "Entities/Player.h"
|
||||||
#include "Inventory.h"
|
#include "Inventory.h"
|
||||||
#include "BlockEntities/ChestEntity.h"
|
#include "BlockEntities/ChestEntity.h"
|
||||||
|
#include "BlockEntities/CommandBlockEntity.h"
|
||||||
#include "BlockEntities/SignEntity.h"
|
#include "BlockEntities/SignEntity.h"
|
||||||
#include "UI/Window.h"
|
#include "UI/Window.h"
|
||||||
#include "Item.h"
|
#include "Item.h"
|
||||||
|
@ -545,6 +546,15 @@ void cClientHandle::HandlePlayerPos(double a_PosX, double a_PosY, double a_PosZ,
|
||||||
|
|
||||||
void cClientHandle::HandlePluginMessage(const AString & a_Channel, const AString & a_Message)
|
void cClientHandle::HandlePluginMessage(const AString & a_Channel, const AString & a_Message)
|
||||||
{
|
{
|
||||||
|
if (a_Channel == "MC|AdvCdm") // Command block
|
||||||
|
{
|
||||||
|
const char* Data = a_Message.c_str();
|
||||||
|
|
||||||
|
HandleCommandBlockMessage(Data, a_Message.size());
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cPluginManager::Get()->CallHookPluginMessage(*this, a_Channel, a_Message);
|
cPluginManager::Get()->CallHookPluginMessage(*this, a_Channel, a_Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,6 +562,60 @@ void cClientHandle::HandlePluginMessage(const AString & a_Channel, const AString
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cClientHandle::HandleCommandBlockMessage(const char* a_Data, unsigned int a_Length)
|
||||||
|
{
|
||||||
|
if (a_Length < 14)
|
||||||
|
{
|
||||||
|
LOGD("Malformed MC|AdvCdm packet.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int BlockX, BlockY, BlockZ;
|
||||||
|
|
||||||
|
AString Command;
|
||||||
|
|
||||||
|
switch (a_Data[0])
|
||||||
|
{
|
||||||
|
case 0x00:
|
||||||
|
{
|
||||||
|
BlockX = GetBEInt(a_Data + 1);
|
||||||
|
BlockY = GetBEInt(a_Data + 5);
|
||||||
|
BlockZ = GetBEInt(a_Data + 9);
|
||||||
|
|
||||||
|
Command = AString(a_Data + 14, (int)a_Data[13]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
LOGD("Unhandled MC|AdvCdm packet mode.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class cUpdateCommandBlock :
|
||||||
|
public cCommandBlockCallback
|
||||||
|
{
|
||||||
|
AString m_Command;
|
||||||
|
public:
|
||||||
|
cUpdateCommandBlock(const AString & a_Command) : m_Command(a_Command) {}
|
||||||
|
|
||||||
|
virtual bool Item(cCommandBlockEntity * a_CommandBlock) override
|
||||||
|
{
|
||||||
|
a_CommandBlock->SetCommand(m_Command);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} CmdBlockCB (Command);
|
||||||
|
|
||||||
|
cWorld * World = m_Player->GetWorld();
|
||||||
|
|
||||||
|
World->DoWithCommandBlockAt(BlockX, BlockY, BlockZ, CmdBlockCB);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status)
|
void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status)
|
||||||
{
|
{
|
||||||
LOGD("HandleLeftClick: {%i, %i, %i}; Face: %i; Stat: %i",
|
LOGD("HandleLeftClick: {%i, %i, %i}; Face: %i; Stat: %i",
|
||||||
|
|
|
@ -324,6 +324,9 @@ private:
|
||||||
|
|
||||||
/// Handles the DIG_FINISHED dig packet:
|
/// Handles the DIG_FINISHED dig packet:
|
||||||
void HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta);
|
void HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta);
|
||||||
|
|
||||||
|
/// Handles the "MC|AdvCdm" plugin message
|
||||||
|
void HandleCommandBlockMessage(const char* a_Data, unsigned int a_Length);
|
||||||
|
|
||||||
// cSocketThreads::cCallback overrides:
|
// cSocketThreads::cCallback overrides:
|
||||||
virtual void DataReceived (const char * a_Data, int a_Size) override; // Data is received from the client
|
virtual void DataReceived (const char * a_Data, int a_Size) override; // Data is received from the client
|
||||||
|
|
|
@ -236,7 +236,7 @@ void cNBTChunkSerializer::AddCommandBlockEntity(cCommandBlockEntity * a_CmdBlock
|
||||||
m_Writer.AddString("Command", a_CmdBlock->GetCommand());
|
m_Writer.AddString("Command", a_CmdBlock->GetCommand());
|
||||||
m_Writer.AddInt ("SuccessCount", a_CmdBlock->GetResult());
|
m_Writer.AddInt ("SuccessCount", a_CmdBlock->GetResult());
|
||||||
m_Writer.AddString("LastOutput", a_CmdBlock->GetLastOutput());
|
m_Writer.AddString("LastOutput", a_CmdBlock->GetLastOutput());
|
||||||
m_Writer.AddByte ("TrackOutput", 1); // Unknown (?)
|
m_Writer.AddByte ("TrackOutput", 1); // TODO 2014-01-18 xdot: Figure out what TrackOutput is and save it.
|
||||||
m_Writer.EndCompound();
|
m_Writer.EndCompound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user