summaryrefslogtreecommitdiffstats
path: root/source/cBlockEntity.h
diff options
context:
space:
mode:
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