1
0

Fixed Minecart spawning issues

Now you can have everything!
This commit is contained in:
Tiger Wang 2013-08-28 22:13:27 +01:00
parent fa7def847b
commit 1e91002229
10 changed files with 41 additions and 34 deletions

View File

@ -1901,9 +1901,9 @@ void cClientHandle::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType) void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleTypeType) // VehicleTypeType is specific to Minecarts
{ {
m_Protocol->SendSpawnVehicle(a_Vehicle, a_VehicleType); m_Protocol->SendSpawnVehicle(a_Vehicle, a_VehicleType, a_VehicleTypeType);
} }

View File

@ -125,7 +125,7 @@ public:
void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock); void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock);
void SendSpawnMob (const cMonster & a_Mob); void SendSpawnMob (const cMonster & a_Mob);
void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch); void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch);
void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType); void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleTypeType);
void SendTabCompletionResults(const AStringVector & a_Results); void SendTabCompletionResults(const AStringVector & a_Results);
void SendTeleportEntity (const cEntity & a_Entity); void SendTeleportEntity (const cEntity & a_Entity);
void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ); void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ);

View File

@ -18,7 +18,8 @@ cMinecart::cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z) :
super(etMinecart, a_X, a_Y, a_Z, 0.98, 0.7), super(etMinecart, a_X, a_Y, a_Z, 0.98, 0.7),
m_Payload(a_Payload) m_Payload(a_Payload)
{ {
m_Mass = 20.f; SetMass(20.f);
SetMaxHealth(6);
} }
@ -40,21 +41,21 @@ bool cMinecart::Initialize(cWorld * a_World)
void cMinecart::SpawnOn(cClientHandle & a_ClientHandle) void cMinecart::SpawnOn(cClientHandle & a_ClientHandle)
{ {
char Type = 0; char TypeType = 0;
switch (m_Payload) //Wiki.vg is outdated on this!! switch (m_Payload)
{ {
case mpNone: Type = 9; break; //? case mpNone: TypeType = 0; break;
case mpChest: Type = 10; break; case mpChest: TypeType = 1; break;
case mpFurnace: Type = 11; break; //? case mpFurnace: TypeType = 2; break;
case mpTNT: Type = 12; break; //? case mpTNT: TypeType = 3; break;
case mpHopper: Type = 13; break; //? case mpHopper: TypeType = 5; break;
default: default:
{ {
ASSERT(!"Unknown payload, cannot spawn on client"); ASSERT(!"Unknown payload, cannot spawn on client");
return; return;
} }
} }
a_ClientHandle.SendSpawnVehicle(*this, Type); a_ClientHandle.SendSpawnVehicle(*this, 10, TypeType); // 10 = Minecarts, TypeType = What type of Minecart
} }

View File

@ -89,7 +89,7 @@ public:
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) = 0; virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) = 0;
virtual void SendSpawnMob (const cMonster & a_Mob) = 0; virtual void SendSpawnMob (const cMonster & a_Mob) = 0;
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) = 0; virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) = 0;
virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType) = 0; virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleTypeType) = 0;
virtual void SendTabCompletionResults(const AStringVector & a_Results) = 0; virtual void SendTabCompletionResults(const AStringVector & a_Results) = 0;
virtual void SendTeleportEntity (const cEntity & a_Entity) = 0; virtual void SendTeleportEntity (const cEntity & a_Entity) = 0;
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) = 0; virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) = 0;

View File

@ -747,7 +747,7 @@ void cProtocol125::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
void cProtocol125::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType) void cProtocol125::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleTypeType)
{ {
cCSLock Lock(m_CSPacket); cCSLock Lock(m_CSPacket);
WriteByte (PACKET_SPAWN_OBJECT); WriteByte (PACKET_SPAWN_OBJECT);
@ -758,10 +758,13 @@ void cProtocol125::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleTyp
WriteInt ((int)(a_Vehicle.GetPosZ() * 32)); WriteInt ((int)(a_Vehicle.GetPosZ() * 32));
WriteByte ((Byte)((a_Vehicle.GetPitch() / 360.f) * 256)); WriteByte ((Byte)((a_Vehicle.GetPitch() / 360.f) * 256));
WriteByte ((Byte)((a_Vehicle.GetRotation() / 360.f) * 256)); WriteByte ((Byte)((a_Vehicle.GetRotation() / 360.f) * 256));
WriteInt (1); WriteInt (a_VehicleTypeType);
WriteShort((short)(a_Vehicle.GetSpeedX() * 400)); if (a_VehicleTypeType != 0)
WriteShort((short)(a_Vehicle.GetSpeedY() * 400)); {
WriteShort((short)(a_Vehicle.GetSpeedZ() * 400)); WriteShort((short)(a_Vehicle.GetSpeedX() * 400));
WriteShort((short)(a_Vehicle.GetSpeedY() * 400));
WriteShort((short)(a_Vehicle.GetSpeedZ() * 400));
}
Flush(); Flush();
} }

View File

@ -66,7 +66,7 @@ public:
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override; virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override;
virtual void SendSpawnMob (const cMonster & a_Mob) override; virtual void SendSpawnMob (const cMonster & a_Mob) override;
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override; virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override;
virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType) override; virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleTypeType) override;
virtual void SendTabCompletionResults(const AStringVector & a_Results) override; virtual void SendTabCompletionResults(const AStringVector & a_Results) override;
virtual void SendTeleportEntity (const cEntity & a_Entity) override; virtual void SendTeleportEntity (const cEntity & a_Entity) override;
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override;

View File

@ -229,21 +229,24 @@ void cProtocol146::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
void cProtocol146::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType) void cProtocol146::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleTypeType)
{ {
cCSLock Lock(m_CSPacket); cCSLock Lock(m_CSPacket);
WriteByte(PACKET_SPAWN_OBJECT); WriteByte (PACKET_SPAWN_OBJECT);
WriteInt (a_Vehicle.GetUniqueID()); WriteInt (a_Vehicle.GetUniqueID());
WriteByte(a_VehicleType); WriteByte (a_VehicleType);
WriteInt ((int)(a_Vehicle.GetPosX() * 32)); WriteInt ((int)(a_Vehicle.GetPosX() * 32));
WriteInt ((int)(a_Vehicle.GetPosY() * 32)); WriteInt ((int)(a_Vehicle.GetPosY() * 32));
WriteInt ((int)(a_Vehicle.GetPosZ() * 32)); WriteInt ((int)(a_Vehicle.GetPosZ() * 32));
WriteByte ((Byte)((a_Vehicle.GetPitch() / 360.f) * 256)); WriteByte ((Byte)((a_Vehicle.GetPitch() / 360.f) * 256));
WriteByte ((Byte)((a_Vehicle.GetRotation() / 360.f) * 256)); WriteByte ((Byte)((a_Vehicle.GetRotation() / 360.f) * 256));
WriteInt (1); WriteInt (a_VehicleTypeType);
WriteShort((short)(a_Vehicle.GetSpeedX() * 400)); if (a_VehicleTypeType != 0)
WriteShort((short)(a_Vehicle.GetSpeedY() * 400)); {
WriteShort((short)(a_Vehicle.GetSpeedZ() * 400)); WriteShort((short)(a_Vehicle.GetSpeedX() * 400));
WriteShort((short)(a_Vehicle.GetSpeedY() * 400));
WriteShort((short)(a_Vehicle.GetSpeedZ() * 400));
}
Flush(); Flush();
} }

View File

@ -55,7 +55,7 @@ public:
virtual void SendPickupSpawn (const cPickup & a_Pickup) override; virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
virtual void SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock) override; virtual void SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock) override;
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override; virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override;
virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType) override; virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleTypeType) override;
} ; } ;

View File

@ -502,10 +502,10 @@ void cProtocolRecognizer::SendSpawnObject(const cEntity & a_Entity, char a_Objec
void cProtocolRecognizer::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType) void cProtocolRecognizer::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleTypeType)
{ {
ASSERT(m_Protocol != NULL); ASSERT(m_Protocol != NULL);
m_Protocol->SendSpawnVehicle(a_Vehicle, a_VehicleType); m_Protocol->SendSpawnVehicle(a_Vehicle, a_VehicleType, a_VehicleTypeType);
} }

View File

@ -96,7 +96,7 @@ public:
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override; virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override;
virtual void SendSpawnMob (const cMonster & a_Mob) override; virtual void SendSpawnMob (const cMonster & a_Mob) override;
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override; virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override;
virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType) override; virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleTypeType) override;
virtual void SendTabCompletionResults(const AStringVector & a_Results) override; virtual void SendTabCompletionResults(const AStringVector & a_Results) override;
virtual void SendTeleportEntity (const cEntity & a_Entity) override; virtual void SendTeleportEntity (const cEntity & a_Entity) override;
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override;