summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkeyboard.osh@gmail.com <keyboard.osh@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-28 07:08:29 +0200
committerkeyboard.osh@gmail.com <keyboard.osh@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-28 07:08:29 +0200
commit9e38229b0d37e1a52507325437ccef5e7eb33573 (patch)
tree5d60aa9393208a7b7d166f813194c599878a497a
parentAdded initialization of rotation in cEntity. (diff)
downloadcuberite-9e38229b0d37e1a52507325437ccef5e7eb33573.tar
cuberite-9e38229b0d37e1a52507325437ccef5e7eb33573.tar.gz
cuberite-9e38229b0d37e1a52507325437ccef5e7eb33573.tar.bz2
cuberite-9e38229b0d37e1a52507325437ccef5e7eb33573.tar.lz
cuberite-9e38229b0d37e1a52507325437ccef5e7eb33573.tar.xz
cuberite-9e38229b0d37e1a52507325437ccef5e7eb33573.tar.zst
cuberite-9e38229b0d37e1a52507325437ccef5e7eb33573.zip
-rw-r--r--source/Protocol/Protocol125.cpp16
-rw-r--r--source/Protocol/Protocol132.cpp12
-rw-r--r--source/Protocol/Protocol14x.cpp29
3 files changed, 30 insertions, 27 deletions
diff --git a/source/Protocol/Protocol125.cpp b/source/Protocol/Protocol125.cpp
index 184bd1d30..b9048bdbe 100644
--- a/source/Protocol/Protocol125.cpp
+++ b/source/Protocol/Protocol125.cpp
@@ -711,12 +711,14 @@ void cProtocol125::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
WriteInt ((int)(a_Entity.GetPosX() * 32));
WriteInt ((int)(a_Entity.GetPosY() * 32));
WriteInt ((int)(a_Entity.GetPosZ() * 32));
+ WriteByte(a_Pitch);
+ WriteByte(a_Yaw);
WriteInt (a_ObjectData);
if (a_ObjectData != 0)
{
- WriteShort((short)a_Entity.GetSpeedX());
- WriteShort((short)a_Entity.GetSpeedY());
- WriteShort((short)a_Entity.GetSpeedZ());
+ WriteShort((short)(a_Entity.GetSpeedX() * 400));
+ WriteShort((short)(a_Entity.GetSpeedY() * 400));
+ WriteShort((short)(a_Entity.GetSpeedZ() * 400));
}
Flush();
}
@@ -734,10 +736,12 @@ void cProtocol125::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleTyp
WriteInt ((int)(a_Vehicle.GetPosX() * 32));
WriteInt ((int)(a_Vehicle.GetPosY() * 32));
WriteInt ((int)(a_Vehicle.GetPosZ() * 32));
+ WriteByte ((BYTE)((a_Vehicle.GetPitch() / 360.f) * 256));
+ WriteByte ((BYTE)((a_Vehicle.GetRotation() / 360.f) * 256));
WriteInt (1);
- WriteShort(0); // TODO: SpeedX
- WriteShort(0); // TODO: SpeedY
- WriteShort(0); // TODO: SpeedZ
+ WriteShort((short)(a_Vehicle.GetSpeedX() * 400));
+ WriteShort((short)(a_Vehicle.GetSpeedY() * 400));
+ WriteShort((short)(a_Vehicle.GetSpeedZ() * 400));
Flush();
}
diff --git a/source/Protocol/Protocol132.cpp b/source/Protocol/Protocol132.cpp
index e051bcfa1..213fa26ae 100644
--- a/source/Protocol/Protocol132.cpp
+++ b/source/Protocol/Protocol132.cpp
@@ -406,12 +406,12 @@ void cProtocol132::SendSpawnMob(const cMonster & a_Mob)
WriteInt (a_Mob.GetUniqueID());
WriteByte (a_Mob.GetMobType());
WriteVectorI((Vector3i)(a_Mob.GetPosition() * 32));
- WriteByte (0); // yaw
- WriteByte (0); // pitch
- WriteByte (0); // head yaw
- WriteShort (0); // Velocity Z
- WriteShort (0); // Velocity X
- WriteShort (0); // Velocity Y
+ WriteByte ((BYTE)((a_Mob.GetRotation() / 360.f) * 256));
+ WriteByte ((BYTE)((a_Mob.GetPitch() / 360.f) * 256));
+ WriteByte ((BYTE)((a_Mob.GetHeadYaw() / 360.f) * 256));
+ WriteShort ((short)(a_Mob.GetSpeedX() * 400));
+ WriteShort ((short)(a_Mob.GetSpeedY() * 400));
+ WriteShort ((short)(a_Mob.GetSpeedZ() * 400));
AString MetaData = GetEntityMetaData(a_Mob);
SendData (MetaData.data(), MetaData.size());
Flush();
diff --git a/source/Protocol/Protocol14x.cpp b/source/Protocol/Protocol14x.cpp
index c5597e041..a3a6755b3 100644
--- a/source/Protocol/Protocol14x.cpp
+++ b/source/Protocol/Protocol14x.cpp
@@ -191,12 +191,12 @@ void cProtocol146::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
WriteInt ((int)(a_FallingBlock.GetPosX() * 32));
WriteInt ((int)(a_FallingBlock.GetPosY() * 32));
WriteInt ((int)(a_FallingBlock.GetPosZ() * 32));
- WriteByte (0); // Yaw
WriteByte (0); // Pitch
+ WriteByte (0); // Yaw
WriteInt (a_FallingBlock.GetBlockType()); // data indicator = blocktype
- WriteShort(0); // SpeedX
- WriteShort(0); // SpeedY
- WriteShort(0); // SpeedZ
+ WriteShort((short)(a_FallingBlock.GetSpeedX() * 400));
+ WriteShort((short)(a_FallingBlock.GetSpeedY() * 400));
+ WriteShort((short)(a_FallingBlock.GetSpeedZ() * 400));
Flush();
}
@@ -213,15 +213,14 @@ void cProtocol146::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
WriteInt ((int)(a_Entity.GetPosX() * 32));
WriteInt ((int)(a_Entity.GetPosY() * 32));
WriteInt ((int)(a_Entity.GetPosZ() * 32));
+ WriteByte(a_Pitch);
+ WriteByte(a_Yaw);
WriteInt (a_ObjectData);
if (a_ObjectData != 0)
{
- // TODO: Proper speed units
- WriteShort((short)a_Entity.GetSpeedX());
- WriteShort((short)a_Entity.GetSpeedY());
- WriteShort((short)a_Entity.GetSpeedZ());
- WriteByte(a_Yaw);
- WriteByte(a_Pitch);
+ WriteShort((short)(a_Entity.GetSpeedX() * 400));
+ WriteShort((short)(a_Entity.GetSpeedY() * 400));
+ WriteShort((short)(a_Entity.GetSpeedZ() * 400));
}
Flush();
}
@@ -239,12 +238,12 @@ void cProtocol146::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleTyp
WriteInt ((int)(a_Vehicle.GetPosX() * 32));
WriteInt ((int)(a_Vehicle.GetPosY() * 32));
WriteInt ((int)(a_Vehicle.GetPosZ() * 32));
+ WriteByte ((BYTE)((a_Vehicle.GetPitch() / 360.f) * 256));
+ WriteByte ((BYTE)((a_Vehicle.GetRotation() / 360.f) * 256));
WriteInt (1);
- WriteShort(0); // TODO: SpeedX
- WriteShort(0); // TODO: SpeedY
- WriteShort(0); // TODO: SpeedZ
- WriteByte (0); // TODO: Yaw
- WriteByte (0); // TODO: Pitch
+ WriteShort((short)(a_Vehicle.GetSpeedX() * 400));
+ WriteShort((short)(a_Vehicle.GetSpeedY() * 400));
+ WriteShort((short)(a_Vehicle.GetSpeedZ() * 400));
Flush();
}