summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/Protocol')
-rw-r--r--src/Protocol/Protocol.h2
-rw-r--r--src/Protocol/Protocol125.cpp206
-rw-r--r--src/Protocol/Protocol125.h2
-rw-r--r--src/Protocol/Protocol17x.cpp218
-rw-r--r--src/Protocol/Protocol17x.h2
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp10
-rw-r--r--src/Protocol/ProtocolRecognizer.h1
7 files changed, 441 insertions, 0 deletions
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index 8e1842ec1..16f686b48 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -28,6 +28,7 @@ class cPickup;
class cPainting;
class cWorld;
class cMonster;
+class cNewMonster;
class cChunkDataSerializer;
class cFallingBlock;
class cCompositeChat;
@@ -110,6 +111,7 @@ public:
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 SendSpawnMob (const cNewMonster & 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 SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) = 0;
virtual void SendStatistics (const cStatManager & a_Manager) = 0;
diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp
index a66c64309..6cb5e5638 100644
--- a/src/Protocol/Protocol125.cpp
+++ b/src/Protocol/Protocol125.cpp
@@ -19,6 +19,7 @@ Documentation:
#include "../Entities/Entity.h"
#include "../Entities/ExpOrb.h"
#include "../Mobs/Monster.h"
+#include "../Mobs/NewMonster.h"
#include "../Entities/Pickup.h"
#include "../Entities/Player.h"
#include "../ChatColor.h"
@@ -949,6 +950,28 @@ void cProtocol125::SendSpawnMob(const cMonster & a_Mob)
+void cProtocol125::SendSpawnMob(const cNewMonster & a_Mob)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_SPAWN_MOB);
+ WriteInt (a_Mob.GetUniqueID());
+ WriteByte ((Byte)a_Mob.GetMobType());
+ WriteVectorI((Vector3i)(a_Mob.GetPosition() * 32));
+ WriteByte (0);
+ WriteByte (0);
+ WriteByte (0);
+
+ WriteCommonMetadata(a_Mob);
+ WriteMobMetadata(a_Mob);
+ WriteByte(0x7f);
+
+ Flush();
+}
+
+
+
+
+
void cProtocol125::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch)
{
UNUSED(a_Yaw);
@@ -2126,6 +2149,189 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
}
}
+void cProtocol125::WriteMobMetadata(const cNewMonster & a_Mob)
+{
+ switch (a_Mob.GetMobType())
+ {
+ case cNewMonster::mtCreeper:
+ {
+ // WriteByte(0x10);
+ // WriteChar(((const cCreeper &)a_Mob).IsBlowing() ? 1 : -1); // Blowing up?
+ // WriteByte(0x11);
+ // WriteByte(((const cCreeper &)a_Mob).IsCharged() ? 1 : 0); // Lightning-charged?
+ break;
+ }
+ case cNewMonster::mtBat:
+ {
+ // WriteByte(0x10);
+ // WriteByte(((const cBat &)a_Mob).IsHanging() ? 1 : 0); // Upside down?
+ break;
+ }
+ case cNewMonster::mtPig:
+ {
+ // WriteByte(0x10);
+ // WriteByte(((const cPig &)a_Mob).IsSaddled() ? 1 : 0); // Saddled?
+ break;
+ }
+ case cNewMonster::mtVillager:
+ {
+ // WriteByte(0x50);
+ // WriteInt(((const cVillager &)a_Mob).GetVilType()); // What sort of TESTIFICATE?
+ break;
+ }
+ case cNewMonster::mtZombie:
+ {
+ // WriteByte(0xC);
+ // WriteByte(((const cZombie &)a_Mob).IsBaby() ? 1 : 0); // Baby zombie?
+ // WriteByte(0xD);
+ // WriteByte(((const cZombie &)a_Mob).IsVillagerZombie() ? 1 : 0); // Converted zombie?
+ // WriteByte(0xE);
+ // WriteByte(((const cZombie &)a_Mob).IsConverting() ? 1 : 0); // Converted-but-converting-back zombllager?
+ break;
+ }
+ case cNewMonster::mtGhast:
+ {
+ // WriteByte(0x10);
+ // WriteByte(((const cGhast &)a_Mob).IsCharging()); // About to spit a flameball?
+ break;
+ }
+ case cNewMonster::mtWolf:
+ {
+ // Byte WolfStatus = 0;
+ // if (((const cWolf &)a_Mob).IsSitting())
+ // {
+ // WolfStatus |= 0x1;
+ // }
+ // if (((const cWolf &)a_Mob).IsAngry())
+ // {
+ // WolfStatus |= 0x2;
+ // }
+ // if (((const cWolf &)a_Mob).IsTame())
+ // {
+ // WolfStatus |= 0x4;
+ // }
+ // WriteByte(0x10);
+ // WriteByte(WolfStatus);
+
+ // WriteByte(0x72);
+ // WriteFloat((float)(a_Mob.GetHealth())); // Tail health-o-meter (only shown when tamed, by the way)
+ // WriteByte(0x13);
+ // WriteByte(((const cWolf &)a_Mob).IsBegging() ? 1 : 0); // Ultra cute mode?
+ break;
+ }
+ case cNewMonster::mtSheep:
+ {
+ // [1](1111)
+ // [] = Is sheared? () = Color, from 0 to 15
+
+ // WriteByte(0x10);
+ // Byte SheepMetadata = 0;
+ // SheepMetadata = (Byte)((const cSheep &)a_Mob).GetFurColor();
+
+ // if (((const cSheep &)a_Mob).IsSheared())
+ // {
+ // SheepMetadata |= 0x16;
+ // }
+ // WriteByte(SheepMetadata);
+ break;
+ }
+ case cNewMonster::mtEnderman:
+ {
+ // WriteByte(0x10);
+ // WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedBlock())); // Block that he stole from your house
+ // WriteByte(0x11);
+ // WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedMeta())); // Meta of block that he stole from your house
+ // WriteByte(0x12);
+ // WriteByte(((const cEnderman &)a_Mob).IsScreaming() ? 1 : 0); // Screaming at your face?
+ break;
+ }
+ case cNewMonster::mtSkeleton:
+ {
+ // WriteByte(0xD);
+ // WriteByte(((const cSkeleton &)a_Mob).IsWither() ? 1 : 0); // It's a skeleton, but it's not
+ break;
+ }
+ case cNewMonster::mtWitch:
+ {
+ // WriteByte(0x15);
+ // WriteByte(((const cWitch &)a_Mob).IsAngry() ? 1 : 0); // Aggravated? Doesn't seem to do anything
+ break;
+ }
+ case cNewMonster::mtWither:
+ {
+ // WriteByte(0x54); // Int at index 20
+ // WriteInt((Int32)((const cWither &)a_Mob).GetWitherInvulnerableTicks());
+ // WriteByte(0x66); // Float at index 6
+ // WriteFloat((float)(a_Mob.GetHealth()));
+ break;
+ }
+ case cNewMonster::mtSlime:
+ case cNewMonster::mtMagmaCube:
+ {
+ // WriteByte(0x10);
+ // if (a_Mob.GetMobType() == cMonster::mtSlime)
+ // {
+ // WriteByte((Byte)((const cSlime &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME
+ // }
+ // else
+ // {
+ // WriteByte((Byte)((const cMagmaCube &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME
+ // }
+ break;
+ }
+ case cNewMonster::mtHorse:
+ {
+ // int Flags = 0;
+ // if (((const cHorse &)a_Mob).IsTame())
+ // {
+ // Flags |= 0x2;
+ // }
+ // if (((const cHorse &)a_Mob).IsSaddled())
+ // {
+ // Flags |= 0x4;
+ // }
+ // if (((const cHorse &)a_Mob).IsChested())
+ // {
+ // Flags |= 0x8;
+ // }
+ // if (((const cHorse &)a_Mob).IsBaby())
+ // {
+ // Flags |= 0x10; // IsBred flag, according to wiki.vg - don't think it does anything in multiplayer
+ // }
+ // if (((const cHorse &)a_Mob).IsEating())
+ // {
+ // Flags |= 0x20;
+ // }
+ // if (((const cHorse &)a_Mob).IsRearing())
+ // {
+ // Flags |= 0x40;
+ // }
+ // if (((const cHorse &)a_Mob).IsMthOpen())
+ // {
+ // Flags |= 0x80;
+ // }
+ // WriteByte(0x50);
+ // WriteInt(Flags);
+
+ // WriteByte(0x13);
+ // WriteByte((Byte)((const cHorse &)a_Mob).GetHorseType()); // Type of horse (donkey, chestnut, etc.)
+
+ // WriteByte(0x54);
+ // int Appearance = 0;
+ // Appearance = ((const cHorse &)a_Mob).GetHorseColor(); // Mask FF
+ // Appearance |= ((const cHorse &)a_Mob).GetHorseStyle() * 256; // Mask FF00, so multiply by 256
+ // WriteInt(Appearance);
+
+ // WriteByte(0x56);
+ // WriteInt(((const cHorse &)a_Mob).GetHorseArmour()); // Horshey armour
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+}
diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h
index 1063777a2..cab86faa0 100644
--- a/src/Protocol/Protocol125.h
+++ b/src/Protocol/Protocol125.h
@@ -82,6 +82,7 @@ public:
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 SendSpawnMob (const cNewMonster & 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 SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) override;
virtual void SendStatistics (const cStatManager & a_Manager) override;
@@ -174,6 +175,7 @@ protected:
/// Writes mobile entity metadata
void WriteMobMetadata(const cMonster & a_Mob);
+ void WriteMobMetadata(const cNewMonster & a_Mob);
} ;
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 56e73c1c1..c2aea69da 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -35,6 +35,7 @@ Implements the 1.7.x protocol classes:
#include "../Entities/FireworkEntity.h"
#include "../Mobs/IncludeAllMonsters.h"
+#include "../Mobs/NewMonster.h"
#include "../UI/Window.h"
#include "../BlockEntities/BeaconEntity.h"
@@ -1168,6 +1169,30 @@ void cProtocol172::SendSpawnMob(const cMonster & a_Mob)
+void cProtocol172::SendSpawnMob(const cNewMonster & a_Mob)
+{
+ ASSERT(m_State == 3); // In game mode?
+
+ cPacketizer Pkt(*this, 0x0f); // Spawn Mob packet
+ Pkt.WriteVarInt(a_Mob.GetUniqueID());
+ Pkt.WriteByte((Byte)a_Mob.GetMobType());
+ Pkt.WriteFPInt(a_Mob.GetPosX());
+ Pkt.WriteFPInt(a_Mob.GetPosY());
+ Pkt.WriteFPInt(a_Mob.GetPosZ());
+ Pkt.WriteByteAngle(a_Mob.GetPitch());
+ Pkt.WriteByteAngle(a_Mob.GetHeadYaw());
+ Pkt.WriteByteAngle(a_Mob.GetYaw());
+ Pkt.WriteShort((short)(a_Mob.GetSpeedX() * 400));
+ Pkt.WriteShort((short)(a_Mob.GetSpeedY() * 400));
+ Pkt.WriteShort((short)(a_Mob.GetSpeedZ() * 400));
+ Pkt.WriteEntityMetadata(a_Mob);
+ Pkt.WriteByte(0x7f); // Metadata terminator
+}
+
+
+
+
+
void cProtocol172::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch)
{
ASSERT(m_State == 3); // In game mode?
@@ -3002,6 +3027,199 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
+void cProtocol172::cPacketizer::WriteMobMetadata(const cNewMonster & a_Mob)
+{
+ switch (a_Mob.GetMobType())
+ {
+ case cMonster::mtCreeper:
+ {
+ // WriteByte(0x10);
+ // WriteByte(((const cCreeper &)a_Mob).IsBlowing() ? 1 : -1);
+ // WriteByte(0x11);
+ // WriteByte(((const cCreeper &)a_Mob).IsCharged() ? 1 : 0);
+ break;
+ }
+
+ case cMonster::mtBat:
+ {
+ // WriteByte(0x10);
+ // WriteByte(((const cBat &)a_Mob).IsHanging() ? 1 : 0);
+ break;
+ }
+
+ case cMonster::mtPig:
+ {
+ // WriteByte(0x10);
+ // WriteByte(((const cPig &)a_Mob).IsSaddled() ? 1 : 0);
+ break;
+ }
+
+ case cMonster::mtVillager:
+ {
+ // WriteByte(0x50);
+ // WriteInt(((const cVillager &)a_Mob).GetVilType());
+ break;
+ }
+
+ case cMonster::mtZombie:
+ {
+ // WriteByte(0x0c);
+ // WriteByte(((const cZombie &)a_Mob).IsBaby() ? 1 : 0);
+ // WriteByte(0x0d);
+ // WriteByte(((const cZombie &)a_Mob).IsVillagerZombie() ? 1 : 0);
+ // WriteByte(0x0e);
+ // WriteByte(((const cZombie &)a_Mob).IsConverting() ? 1 : 0);
+ break;
+ }
+
+ case cMonster::mtGhast:
+ {
+ // WriteByte(0x10);
+ // WriteByte(((const cGhast &)a_Mob).IsCharging());
+ break;
+ }
+
+ case cMonster::mtWolf:
+ {
+ // const cWolf & Wolf = (const cWolf &)a_Mob;
+ // Byte WolfStatus = 0;
+ // if (Wolf.IsSitting())
+ // {
+ // WolfStatus |= 0x1;
+ // }
+ // if (Wolf.IsAngry())
+ // {
+ // WolfStatus |= 0x2;
+ // }
+ // if (Wolf.IsTame())
+ // {
+ // WolfStatus |= 0x4;
+ // }
+ // WriteByte(0x10);
+ // WriteByte(WolfStatus);
+
+ // WriteByte(0x72);
+ // WriteFloat((float)(a_Mob.GetHealth()));
+ // WriteByte(0x13);
+ // WriteByte(Wolf.IsBegging() ? 1 : 0);
+ // WriteByte(0x14);
+ // WriteByte(Wolf.GetCollarColor());
+ break;
+ }
+
+ case cMonster::mtSheep:
+ {
+ // WriteByte(0x10);
+ // Byte SheepMetadata = 0;
+ // SheepMetadata = ((const cSheep &)a_Mob).GetFurColor();
+ // if (((const cSheep &)a_Mob).IsSheared())
+ // {
+ // SheepMetadata |= 0x10;
+ // }
+ // WriteByte(SheepMetadata);
+ break;
+ }
+
+ case cMonster::mtEnderman:
+ {
+ // WriteByte(0x10);
+ // WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedBlock()));
+ // WriteByte(0x11);
+ // WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedMeta()));
+ // WriteByte(0x12);
+ // WriteByte(((const cEnderman &)a_Mob).IsScreaming() ? 1 : 0);
+ break;
+ }
+
+ case cMonster::mtSkeleton:
+ {
+ // WriteByte(0x0d);
+ // WriteByte(((const cSkeleton &)a_Mob).IsWither() ? 1 : 0);
+ break;
+ }
+
+ case cMonster::mtWitch:
+ {
+ // WriteByte(0x15);
+ // WriteByte(((const cWitch &)a_Mob).IsAngry() ? 1 : 0);
+ break;
+ }
+
+ case cMonster::mtWither:
+ {
+ // WriteByte(0x54); // Int at index 20
+ // WriteInt(((const cWither &)a_Mob).GetWitherInvulnerableTicks());
+ // WriteByte(0x66); // Float at index 6
+ // WriteFloat((float)(a_Mob.GetHealth()));
+ break;
+ }
+
+ case cMonster::mtSlime:
+ {
+ // WriteByte(0x10);
+ // WriteByte(((const cSlime &)a_Mob).GetSize());
+ break;
+ }
+
+ case cMonster::mtMagmaCube:
+ {
+ // WriteByte(0x10);
+ // WriteByte(((const cMagmaCube &)a_Mob).GetSize());
+ break;
+ }
+
+ case cMonster::mtHorse:
+ {
+ // const cHorse & Horse = (const cHorse &)a_Mob;
+ // int Flags = 0;
+ // if (Horse.IsTame())
+ // {
+ // Flags |= 0x02;
+ // }
+ // if (Horse.IsSaddled())
+ // {
+ // Flags |= 0x04;
+ // }
+ // if (Horse.IsChested())
+ // {
+ // Flags |= 0x08;
+ // }
+ // if (Horse.IsBaby())
+ // {
+ // Flags |= 0x10;
+ // }
+ // if (Horse.IsEating())
+ // {
+ // Flags |= 0x20;
+ // }
+ // if (Horse.IsRearing())
+ // {
+ // Flags |= 0x40;
+ // }
+ // if (Horse.IsMthOpen())
+ // {
+ // Flags |= 0x80;
+ // }
+ // WriteByte(0x50); // Int at index 16
+ // WriteInt(Flags);
+ // WriteByte(0x13); // Byte at index 19
+ // WriteByte(Horse.GetHorseType());
+ // WriteByte(0x54); // Int at index 20
+ // int Appearance = 0;
+ // Appearance = Horse.GetHorseColor();
+ // Appearance |= Horse.GetHorseStyle() << 8;
+ // WriteInt(Appearance);
+ // WriteByte(0x56); // Int at index 22
+ // WriteInt(Horse.GetHorseArmour());
+ break;
+ }
+ } // switch (a_Mob.GetType())
+}
+
+
+
+
+
void cProtocol172::cPacketizer::WriteEntityProperties(const cEntity & a_Entity)
{
if (!a_Entity.IsMob())
diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h
index ccfa19eb6..ef73a043f 100644
--- a/src/Protocol/Protocol17x.h
+++ b/src/Protocol/Protocol17x.h
@@ -114,6 +114,7 @@ public:
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 SendSpawnMob (const cNewMonster & 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 SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) override;
virtual void SendStatistics (const cStatManager & a_Manager) override;
@@ -209,6 +210,7 @@ protected:
void WriteFPInt(double a_Value); // Writes the double value as a 27:5 fixed-point integer
void WriteEntityMetadata(const cEntity & a_Entity); // Writes the metadata for the specified entity, not including the terminating 0x7f
void WriteMobMetadata(const cMonster & a_Mob); // Writes the mob-specific metadata for the specified mob
+ void WriteMobMetadata(const cNewMonster & a_Mob); // Writes the mob-specific metadata for the specified mob
void WriteEntityProperties(const cEntity & a_Entity); // Writes the entity properties for the specified entity, including the Count field
void WriteBlockEntity(const cBlockEntity & a_BlockEntity);
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index 18694572a..543d9bce8 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -656,6 +656,16 @@ void cProtocolRecognizer::SendSpawnMob(const cMonster & a_Mob)
+void cProtocolRecognizer::SendSpawnMob(const cNewMonster & a_Mob)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendSpawnMob(a_Mob);
+}
+
+
+
+
+
void cProtocolRecognizer::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch)
{
ASSERT(m_Protocol != NULL);
diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h
index 28572a8fd..16724cf3a 100644
--- a/src/Protocol/ProtocolRecognizer.h
+++ b/src/Protocol/ProtocolRecognizer.h
@@ -117,6 +117,7 @@ public:
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 SendSpawnMob (const cNewMonster & 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 SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) override;
virtual void SendStatistics (const cStatManager & a_Manager) override;