summaryrefslogtreecommitdiffstats
path: root/source/Protocol
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-12-26 10:12:00 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-12-26 10:12:00 +0100
commit17a2c1b3886ed38b3e5e93238029476866b8c220 (patch)
treee4c4c335456e5d77cd986094ebd0fd4ebe359733 /source/Protocol
parentProtoProxy: more 1.4.6 stuff, now the connection holds stable with the 1.4.6 client. (diff)
downloadcuberite-17a2c1b3886ed38b3e5e93238029476866b8c220.tar
cuberite-17a2c1b3886ed38b3e5e93238029476866b8c220.tar.gz
cuberite-17a2c1b3886ed38b3e5e93238029476866b8c220.tar.bz2
cuberite-17a2c1b3886ed38b3e5e93238029476866b8c220.tar.lz
cuberite-17a2c1b3886ed38b3e5e93238029476866b8c220.tar.xz
cuberite-17a2c1b3886ed38b3e5e93238029476866b8c220.tar.zst
cuberite-17a2c1b3886ed38b3e5e93238029476866b8c220.zip
Diffstat (limited to 'source/Protocol')
-rw-r--r--source/Protocol/Protocol.h2
-rw-r--r--source/Protocol/Protocol125.cpp11
-rw-r--r--source/Protocol/Protocol125.h1
-rw-r--r--source/Protocol/Protocol14x.cpp86
-rw-r--r--source/Protocol/Protocol14x.h5
-rw-r--r--source/Protocol/ProtocolRecognizer.cpp10
-rw-r--r--source/Protocol/ProtocolRecognizer.h1
7 files changed, 88 insertions, 28 deletions
diff --git a/source/Protocol/Protocol.h b/source/Protocol/Protocol.h
index 956d31955..52f3f2e3f 100644
--- a/source/Protocol/Protocol.h
+++ b/source/Protocol/Protocol.h
@@ -25,6 +25,7 @@ class cPickup;
class cMonster;
class cChunkDataSerializer;
class cWorld;
+class cFallingBlock;
@@ -80,6 +81,7 @@ public:
virtual void SendRespawn (void) = 0;
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) = 0; // a_Src coords are Block * 8
virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) = 0;
+ virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) = 0;
virtual void SendSpawnMob (const cMonster & a_Mob) = 0;
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) = 0;
virtual void SendTeleportEntity (const cEntity & a_Entity) = 0;
diff --git a/source/Protocol/Protocol125.cpp b/source/Protocol/Protocol125.cpp
index 821cebfa1..cb1e46193 100644
--- a/source/Protocol/Protocol125.cpp
+++ b/source/Protocol/Protocol125.cpp
@@ -23,6 +23,7 @@ Documentation:
#include "../UI/Window.h"
#include "../Root.h"
#include "../Server.h"
+#include "../FallingBlock.h"
@@ -614,6 +615,16 @@ void cProtocol125::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_Src
+void cProtocol125::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
+{
+ // This protocol version implements falling blocks using the spawn object / vehicle packet:
+ SendSpawnObject(a_FallingBlock, 70, a_FallingBlock.GetBlockType(), 0, 0, 0, 0, 0);
+}
+
+
+
+
+
void cProtocol125::SendSpawnMob(const cMonster & a_Mob)
{
cCSLock Lock(m_CSPacket);
diff --git a/source/Protocol/Protocol125.h b/source/Protocol/Protocol125.h
index 84d4f7f41..ec0d976e5 100644
--- a/source/Protocol/Protocol125.h
+++ b/source/Protocol/Protocol125.h
@@ -58,6 +58,7 @@ public:
virtual void SendRespawn (void) override;
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
+ virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override;
virtual void SendSpawnMob (const cMonster & a_Mob) override;
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) override;
virtual void SendTeleportEntity (const cEntity & a_Entity) override;
diff --git a/source/Protocol/Protocol14x.cpp b/source/Protocol/Protocol14x.cpp
index 5c517cd7f..d9be4948c 100644
--- a/source/Protocol/Protocol14x.cpp
+++ b/source/Protocol/Protocol14x.cpp
@@ -23,6 +23,7 @@ Implements the 1.4.x protocol classes representing these protocols:
#include "../Mobs/Monster.h"
#include "../UI/Window.h"
#include "../Pickup.h"
+#include "../FallingBlock.h"
@@ -152,31 +153,6 @@ cProtocol146::cProtocol146(cClientHandle * a_Client) :
-void cProtocol146::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch)
-{
- cCSLock Lock(m_CSPacket);
- WriteByte(PACKET_SPAWN_OBJECT);
- WriteInt (a_Entity.GetUniqueID());
- WriteByte(a_ObjectType);
- WriteInt ((int)(a_Entity.GetPosX() * 32));
- WriteInt ((int)(a_Entity.GetPosY() * 32));
- WriteInt ((int)(a_Entity.GetPosZ() * 32));
- WriteInt (a_ObjectData);
- if (a_ObjectData != 0)
- {
- WriteShort(a_SpeedX);
- WriteShort(a_SpeedY);
- WriteShort(a_SpeedZ);
- WriteByte(a_Yaw);
- WriteByte(a_Pitch);
- }
- Flush();
-}
-
-
-
-
-
void cProtocol146::SendPickupSpawn(const cPickup & a_Pickup)
{
ASSERT(!a_Pickup.GetItem()->IsEmpty());
@@ -201,7 +177,39 @@ void cProtocol146::SendPickupSpawn(const cPickup & a_Pickup)
WriteByte(PACKET_ENTITY_METADATA);
WriteInt(a_Pickup.GetUniqueID());
WriteByte(0xaa); // a slot value at index 10
- WriteItem(*a_Pickup.GetItem()); // TODO: Still not good, needs GZIP!
+ WriteItem(*a_Pickup.GetItem());
+ WriteByte(0x7f); // End of metadata
+ Flush();
+}
+
+
+
+
+
+void cProtocol146::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
+{
+ // Send two packets - spawn object, then entity metadata
+ cCSLock Lock(m_CSPacket);
+
+ WriteByte(PACKET_SPAWN_OBJECT);
+ WriteInt (a_FallingBlock.GetUniqueID());
+ WriteByte(70);
+ WriteInt ((int)(a_FallingBlock.GetPosX() * 32));
+ WriteInt ((int)(a_FallingBlock.GetPosY() * 32));
+ WriteInt ((int)(a_FallingBlock.GetPosZ() * 32));
+ WriteInt (0x800000);
+ WriteShort(0);
+ WriteShort(0);
+ WriteShort(0);
+ WriteByte (0);
+ WriteByte (0);
+
+ // TODO: This still doesn't work, although it is exactly the same that the vanilla server sends. WTF?
+ WriteByte(PACKET_ENTITY_METADATA);
+ WriteInt(a_FallingBlock.GetUniqueID());
+ WriteByte(0xaa); // a slot value at index 10
+ cItem Item(a_FallingBlock.GetBlockType(), 1);
+ WriteItem(Item);
WriteByte(0x7f); // End of metadata
Flush();
}
@@ -209,3 +217,29 @@ void cProtocol146::SendPickupSpawn(const cPickup & a_Pickup)
+
+void cProtocol146::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_SPAWN_OBJECT);
+ WriteInt (a_Entity.GetUniqueID());
+ WriteByte(a_ObjectType);
+ WriteInt ((int)(a_Entity.GetPosX() * 32));
+ WriteInt ((int)(a_Entity.GetPosY() * 32));
+ WriteInt ((int)(a_Entity.GetPosZ() * 32));
+ WriteInt (a_ObjectData);
+ if (a_ObjectData != 0)
+ {
+ WriteShort(a_SpeedX);
+ WriteShort(a_SpeedY);
+ WriteShort(a_SpeedZ);
+ WriteByte(a_Yaw);
+ WriteByte(a_Pitch);
+ }
+ Flush();
+}
+
+
+
+
+
diff --git a/source/Protocol/Protocol14x.h b/source/Protocol/Protocol14x.h
index bd8706f40..02888e61f 100644
--- a/source/Protocol/Protocol14x.h
+++ b/source/Protocol/Protocol14x.h
@@ -52,8 +52,9 @@ class cProtocol146 :
public:
cProtocol146(cClientHandle * a_Client);
- virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
- virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) override;
+ virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
+ virtual void SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock) override;
+ virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) override;
} ;
diff --git a/source/Protocol/ProtocolRecognizer.cpp b/source/Protocol/ProtocolRecognizer.cpp
index 43ed82a36..4ab163783 100644
--- a/source/Protocol/ProtocolRecognizer.cpp
+++ b/source/Protocol/ProtocolRecognizer.cpp
@@ -406,6 +406,16 @@ void cProtocolRecognizer::SendSoundParticleEffect(int a_EffectID, int a_SrcX, in
+void cProtocolRecognizer::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendSpawnFallingBlock(a_FallingBlock);
+}
+
+
+
+
+
void cProtocolRecognizer::SendSpawnMob(const cMonster & a_Mob)
{
ASSERT(m_Protocol != NULL);
diff --git a/source/Protocol/ProtocolRecognizer.h b/source/Protocol/ProtocolRecognizer.h
index fce5c0ba4..e7505fe3c 100644
--- a/source/Protocol/ProtocolRecognizer.h
+++ b/source/Protocol/ProtocolRecognizer.h
@@ -83,6 +83,7 @@ public:
virtual void SendRespawn (void) override;
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override;
virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
+ virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override;
virtual void SendSpawnMob (const cMonster & a_Mob) override;
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, short a_SpeedX, short a_SpeedY, short a_SpeedZ, Byte a_Yaw, Byte a_Pitch) override;
virtual void SendTeleportEntity (const cEntity & a_Entity) override;