Command block fixes
This commit is contained in:
parent
992053b32a
commit
a037172465
@ -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),
|
super(E_BLOCK_COMMAND_BLOCK, a_X, a_Y, a_Z, a_World),
|
||||||
m_ShouldExecute(false),
|
m_ShouldExecute(false),
|
||||||
m_IsPowered(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)
|
void cCommandBlockEntity::UsedBy(cPlayer * a_Player)
|
||||||
{
|
{
|
||||||
cWindow * Window = GetWindow();
|
// Nothing to do
|
||||||
if (Window == NULL)
|
UNUSED(a_Player);
|
||||||
{
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,8 +9,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BlockEntityWithItems.h"
|
#include "BlockEntity.h"
|
||||||
#include "../UI/WindowOwner.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -28,8 +27,7 @@ namespace Json
|
|||||||
// tolua_begin
|
// tolua_begin
|
||||||
|
|
||||||
class cCommandBlockEntity :
|
class cCommandBlockEntity :
|
||||||
public cBlockEntity,
|
public cBlockEntity
|
||||||
public cBlockEntityWindowOwner
|
|
||||||
{
|
{
|
||||||
typedef cBlockEntity super;
|
typedef cBlockEntity super;
|
||||||
|
|
||||||
@ -39,7 +37,6 @@ public:
|
|||||||
|
|
||||||
/// Creates a new empty command block entity
|
/// Creates a new empty command block entity
|
||||||
cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
|
cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
|
||||||
virtual ~cCommandBlockEntity();
|
|
||||||
|
|
||||||
bool LoadFromJson( const Json::Value& a_Value );
|
bool LoadFromJson( const Json::Value& a_Value );
|
||||||
virtual void SaveToJson(Json::Value& a_Value ) override;
|
virtual void SaveToJson(Json::Value& a_Value ) override;
|
||||||
|
@ -570,19 +570,26 @@ void cClientHandle::HandleCommandBlockMessage(const char* a_Data, unsigned int a
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cByteBuffer Buffer(a_Length);
|
||||||
|
Buffer.Write(a_Data, a_Length);
|
||||||
|
|
||||||
int BlockX, BlockY, BlockZ;
|
int BlockX, BlockY, BlockZ;
|
||||||
|
|
||||||
AString Command;
|
AString Command;
|
||||||
|
|
||||||
switch (a_Data[0])
|
char Mode;
|
||||||
|
|
||||||
|
Buffer.ReadChar(Mode);
|
||||||
|
|
||||||
|
switch (Mode)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
{
|
{
|
||||||
BlockX = GetBEInt(a_Data + 1);
|
Buffer.ReadBEInt(BlockX);
|
||||||
BlockY = GetBEInt(a_Data + 5);
|
Buffer.ReadBEInt(BlockY);
|
||||||
BlockZ = GetBEInt(a_Data + 9);
|
Buffer.ReadBEInt(BlockZ);
|
||||||
|
|
||||||
Command = AString(a_Data + 14, (int)a_Data[13]);
|
Buffer.ReadVarUTF8String(Command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user