summaryrefslogtreecommitdiffstats
path: root/source/cBlockEntity.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-03-05 17:41:57 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-03-05 17:41:57 +0100
commit4d65ffffc0b6f35ac84e310fd4bc9739ea7e0c0a (patch)
treeccc5f55d8f7a15f08bab8f0222fd1b2f95e5d7a2 /source/cBlockEntity.h
parentRemoved redstone debugging: powered dirt blocks change into stone (diff)
downloadcuberite-4d65ffffc0b6f35ac84e310fd4bc9739ea7e0c0a.tar
cuberite-4d65ffffc0b6f35ac84e310fd4bc9739ea7e0c0a.tar.gz
cuberite-4d65ffffc0b6f35ac84e310fd4bc9739ea7e0c0a.tar.bz2
cuberite-4d65ffffc0b6f35ac84e310fd4bc9739ea7e0c0a.tar.lz
cuberite-4d65ffffc0b6f35ac84e310fd4bc9739ea7e0c0a.tar.xz
cuberite-4d65ffffc0b6f35ac84e310fd4bc9739ea7e0c0a.tar.zst
cuberite-4d65ffffc0b6f35ac84e310fd4bc9739ea7e0c0a.zip
Diffstat (limited to '')
-rw-r--r--source/cBlockEntity.h30
1 files changed, 28 insertions, 2 deletions
diff --git a/source/cBlockEntity.h b/source/cBlockEntity.h
index ad1cf14ba..ab0a6c6ca 100644
--- a/source/cBlockEntity.h
+++ b/source/cBlockEntity.h
@@ -1,6 +1,13 @@
#pragma once
+#include "cClientHandle.h"
+#include "cWorld.h"
+
+
+
+
+
#ifndef _WIN32
#include "BlockID.h"
#else
@@ -16,9 +23,9 @@ namespace Json
class Value;
};
-class cClientHandle;
class cPlayer;
class cWorld;
+class cPacket;
@@ -49,7 +56,26 @@ public:
virtual void SaveToJson (Json::Value & a_Value ) = 0;
virtual void UsedBy( cPlayer * a_Player ) = 0;
- virtual void SendTo( cClientHandle* a_Client ) { (void)a_Client; }
+
+ void SendTo( cClientHandle* a_Client )
+ {
+ std::auto_ptr<cPacket> Packet(GetPacket());
+ if (Packet.get() == NULL)
+ {
+ return;
+ }
+ if ( a_Client != NULL )
+ {
+ a_Client->Send(Packet.get());
+ }
+ else // broadcast to all chunk clients
+ {
+ m_World->BroadcastToChunkOfBlock(m_PosX, m_PosY, m_PosZ, Packet.get());
+ }
+ }
+
+ /// Returns the packet to send to clients to represent this entity; NULL if no packet needed; caller is supposed to delete the packet
+ virtual cPacket * GetPacket(void) {return NULL; }
protected:
int m_PosX; // Position in block coordinates