summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
author12xx12 <44411062+12xx12@users.noreply.github.com>2020-11-23 00:41:13 +0100
committerGitHub <noreply@github.com>2020-11-23 00:41:13 +0100
commite35519ec8ab1b958408ab2a90b88dffc1bcc7fb2 (patch)
tree3ed498478eabe7aa01b54f85d8ec9c2bc821fe66 /src/Protocol
parentAdd coloured glass pane recipes (#5032) (diff)
downloadcuberite-e35519ec8ab1b958408ab2a90b88dffc1bcc7fb2.tar
cuberite-e35519ec8ab1b958408ab2a90b88dffc1bcc7fb2.tar.gz
cuberite-e35519ec8ab1b958408ab2a90b88dffc1bcc7fb2.tar.bz2
cuberite-e35519ec8ab1b958408ab2a90b88dffc1bcc7fb2.tar.lz
cuberite-e35519ec8ab1b958408ab2a90b88dffc1bcc7fb2.tar.xz
cuberite-e35519ec8ab1b958408ab2a90b88dffc1bcc7fb2.tar.zst
cuberite-e35519ec8ab1b958408ab2a90b88dffc1bcc7fb2.zip
Diffstat (limited to 'src/Protocol')
-rw-r--r--src/Protocol/Protocol_1_10.cpp62
-rw-r--r--src/Protocol/Protocol_1_10.h1
-rw-r--r--src/Protocol/Protocol_1_11.cpp91
-rw-r--r--src/Protocol/Protocol_1_12.cpp62
-rw-r--r--src/Protocol/Protocol_1_12.h1
-rw-r--r--src/Protocol/Protocol_1_13.cpp86
-rw-r--r--src/Protocol/Protocol_1_8.cpp75
-rw-r--r--src/Protocol/Protocol_1_9.cpp79
-rw-r--r--src/Protocol/Protocol_1_9.h3
9 files changed, 436 insertions, 24 deletions
diff --git a/src/Protocol/Protocol_1_10.cpp b/src/Protocol/Protocol_1_10.cpp
index 6a39589e3..0efef360c 100644
--- a/src/Protocol/Protocol_1_10.cpp
+++ b/src/Protocol/Protocol_1_10.cpp
@@ -337,6 +337,19 @@ cProtocol::Version cProtocol_1_10_0::GetProtocolVersion()
+UInt32 cProtocol_1_10_0::GetProtocolMobType(const eMonsterType a_MobType)
+{
+ switch (a_MobType)
+ {
+ case mtPolarBear: return 102;
+ default: return Super::GetProtocolMobType(a_MobType);
+ }
+}
+
+
+
+
+
void cProtocol_1_10_0::HandlePacketResourcePackStatus(cByteBuffer & a_ByteBuffer)
{
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Status);
@@ -677,7 +690,7 @@ void cProtocol_1_10_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_
{
using namespace Metadata;
- // Living Enitiy Metadata
+ // Living entity metadata
if (a_Mob.HasCustomName())
{
// TODO: As of 1.9 _all_ entities can have custom names; should this be moved up?
@@ -975,6 +988,7 @@ void cProtocol_1_10_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_
break;
} // case mtWolf
+ case mtHusk:
case mtZombie:
{
auto & Zombie = static_cast<const cZombie &>(a_Mob);
@@ -1018,6 +1032,50 @@ void cProtocol_1_10_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_
break;
} // case mtZombieVillager
- default: break;
+ case mtBlaze:
+ case mtElderGuardian:
+ case mtGuardian:
+ {
+ // TODO: Mobs with extra fields that aren't implemented
+ break;
+ }
+ case mtCat:
+
+ case mtEndermite:
+
+ case mtPolarBear:
+
+ case mtShulker:
+
+ case mtDonkey:
+ case mtMule:
+ case mtSkeletonHorse:
+ case mtZombieHorse:
+ {
+ // Todo: Mobs not added yet. Grouped ones have the same metadata
+ UNREACHABLE("cProtocol_1_10::WriteMobMetadata: received unimplemented type");
+ break;
+ }
+
+ case mtCaveSpider:
+ case mtEnderDragon:
+ case mtGiant:
+ case mtIronGolem:
+ case mtMooshroom:
+ case mtSilverfish:
+ case mtSkeleton:
+ case mtSnowGolem:
+ case mtStray:
+ case mtSpider:
+ case mtSquid:
+ {
+ // Entities without additional metadata
+ break;
+ }
+ case mtInvalidType:
+ {
+ break;
+ }
+ default: UNREACHABLE("cProtocol_1_10::WriteMobMetadata: received mob of invalid type");
} // switch (a_Mob.GetType())
}
diff --git a/src/Protocol/Protocol_1_10.h b/src/Protocol/Protocol_1_10.h
index 46e7f7b04..3d78e7079 100644
--- a/src/Protocol/Protocol_1_10.h
+++ b/src/Protocol/Protocol_1_10.h
@@ -33,6 +33,7 @@ protected:
virtual void SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override;
virtual Version GetProtocolVersion() override;
+ virtual UInt32 GetProtocolMobType(eMonsterType a_MobType) override;
virtual void HandlePacketResourcePackStatus(cByteBuffer & a_ByteBuffer) override;
virtual void WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_Entity) override;
virtual void WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) override;
diff --git a/src/Protocol/Protocol_1_11.cpp b/src/Protocol/Protocol_1_11.cpp
index d475bd005..05bf35562 100644
--- a/src/Protocol/Protocol_1_11.cpp
+++ b/src/Protocol/Protocol_1_11.cpp
@@ -378,12 +378,20 @@ void cProtocol_1_11_0::SendSpawnMob(const cMonster & a_Mob)
{
ASSERT(m_State == 3); // In game mode?
+ const auto MobType = GetProtocolMobType(a_Mob.GetMobType());
+
+ // If the type is not valid in this protocol bail out:
+ if (MobType == 0)
+ {
+ return;
+ }
+
cPacketizer Pkt(*this, pktSpawnMob);
Pkt.WriteVarInt32(a_Mob.GetUniqueID());
// TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now.
Pkt.WriteBEUInt64(0);
Pkt.WriteBEUInt64(a_Mob.GetUniqueID());
- Pkt.WriteVarInt32(GetProtocolMobType(a_Mob.GetMobType()));
+ Pkt.WriteVarInt32(MobType);
Vector3d LastSentPos = a_Mob.GetLastSentPosition();
Pkt.WriteBEDouble(LastSentPos.x);
Pkt.WriteBEDouble(LastSentPos.y);
@@ -543,7 +551,7 @@ cProtocol::Version cProtocol_1_11_0::GetProtocolVersion()
-UInt32 cProtocol_1_11_0::GetProtocolMobType(eMonsterType a_MobType)
+UInt32 cProtocol_1_11_0::GetProtocolMobType(const eMonsterType a_MobType)
{
switch (a_MobType)
{
@@ -555,26 +563,38 @@ UInt32 cProtocol_1_11_0::GetProtocolMobType(eMonsterType a_MobType)
case mtChicken: return 93;
case mtCow: return 92;
case mtCreeper: return 50;
+ case mtDonkey: return 31;
case mtEnderDragon: return 63;
case mtEnderman: return 58;
+ case mtEndermite: return 67;
+ case mtEvoker: return 34;
case mtGhast: return 56;
case mtGiant: return 53;
case mtGuardian: return 68;
case mtHorse: return 100;
+ case mtHusk: return 23;
case mtIronGolem: return 99;
+ case mtLlama: return 103;
case mtMagmaCube: return 62;
case mtMooshroom: return 96;
+ case mtMule: return 32;
case mtOcelot: return 98;
case mtPig: return 90;
+ case mtPolarBear: return 102;
case mtRabbit: return 101;
case mtSheep: return 91;
+ case mtShulker: return 69;
case mtSilverfish: return 60;
case mtSkeleton: return 51;
case mtSlime: return 55;
case mtSnowGolem: return 97;
case mtSpider: return 52;
+ case mtStray: return 6;
+ case mtTraderLlama: return 103;
case mtSquid: return 94;
+ case mtVex: return 35;
case mtVillager: return 120;
+ case mtVindicator: return 36;
case mtWitch: return 66;
case mtWither: return 64;
case mtWitherSkeleton: return 5;
@@ -582,8 +602,9 @@ UInt32 cProtocol_1_11_0::GetProtocolMobType(eMonsterType a_MobType)
case mtZombie: return 54;
case mtZombiePigman: return 57;
case mtZombieVillager: return 27;
+
+ default: return 0;
}
- UNREACHABLE("Unsupported mob type");
}
@@ -837,7 +858,7 @@ void cProtocol_1_11_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_
{
using namespace Metadata_1_11;
- // Living Enitiy Metadata
+ // Living entity Metadata
if (a_Mob.HasCustomName())
{
// TODO: As of 1.9 _all_ entities can have custom names; should this be moved up?
@@ -929,7 +950,7 @@ void cProtocol_1_11_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_
case mtHorse:
{
- // XXX This behaves incorrectly with different varients; horses have different entity IDs now
+ // XXX This behaves incorrectly with different variants; horses have different entity IDs now
// Abstract horse
auto & Horse = static_cast<const cHorse &>(a_Mob);
@@ -996,6 +1017,7 @@ void cProtocol_1_11_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_
case mtOcelot:
{
+ // Todo: move unnecessary to cat
auto & Ocelot = static_cast<const cOcelot &>(a_Mob);
a_Pkt.WriteBEUInt8(AGEABLE_BABY);
@@ -1153,7 +1175,7 @@ void cProtocol_1_11_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_
case mtZombie:
{
- // XXX Zombies were also split into new sublcasses; this doesn't handle that.
+ // XXX Zombies were also split into new subclasses; this doesn't handle that.
auto & Zombie = static_cast<const cZombie &>(a_Mob);
a_Pkt.WriteBEUInt8(ZOMBIE_IS_BABY);
a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL);
@@ -1187,7 +1209,62 @@ void cProtocol_1_11_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_
break;
} // case mtZombieVillager
- default: break;
+ case mtBlaze:
+ case mtElderGuardian:
+ case mtGuardian:
+ case mtSnowGolem:
+ {
+ // TODO: Mobs with extra fields that aren't implemented
+ break;
+ }
+
+ case mtCat:
+
+ case mtDonkey:
+ case mtMule:
+
+ case mtEndermite:
+
+ case mtEvoker:
+
+ case mtLlama:
+
+ case mtPolarBear:
+
+ case mtShulker:
+
+ case mtSkeletonHorse:
+ case mtZombieHorse:
+
+ case mtVex:
+
+ case mtVindicator:
+ {
+ // Todo: Mobs not added yet. Grouped ones have the same metadata
+ UNREACHABLE("cProtocol_1_11::WriteMobMetadata: received unimplemented type");
+ break;
+ }
+
+ case mtCaveSpider:
+ case mtEnderDragon:
+ case mtGiant:
+ case mtIronGolem:
+ case mtMooshroom:
+ case mtSilverfish:
+ case mtSkeleton:
+ case mtStray:
+ case mtSpider:
+ case mtSquid:
+ case mtWitherSkeleton:
+ {
+ // Mobs without additional metadata
+ break;
+ }
+ case mtInvalidType:
+ {
+ break;
+ }
+ default: UNREACHABLE("cProtocol_1_11::WriteMobMetadata: received mob of invalid type");
} // switch (a_Mob.GetType())
}
diff --git a/src/Protocol/Protocol_1_12.cpp b/src/Protocol/Protocol_1_12.cpp
index 4e0d2b063..93a1160ee 100644
--- a/src/Protocol/Protocol_1_12.cpp
+++ b/src/Protocol/Protocol_1_12.cpp
@@ -550,7 +550,7 @@ void cProtocol_1_12::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo
{
using namespace Metadata_1_12;
- // Living Enitiy Metadata
+ // Living entity metadata
if (a_Mob.HasCustomName())
{
// TODO: As of 1.9 _all_ entities can have custom names; should this be moved up?
@@ -642,7 +642,7 @@ void cProtocol_1_12::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo
case mtHorse:
{
- // XXX This behaves incorrectly with different varients; horses have different entity IDs now
+ // XXX This behaves incorrectly with different variants; horses have different entity IDs now
// Abstract horse
auto & Horse = static_cast<const cHorse &>(a_Mob);
@@ -866,7 +866,7 @@ void cProtocol_1_12::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo
case mtZombie:
{
- // XXX Zombies were also split into new sublcasses; this doesn't handle that.
+ // XXX Zombies were also split into new subclasses; this doesn't handle that.
auto & Zombie = static_cast<const cZombie &>(a_Mob);
a_Pkt.WriteBEUInt8(ZOMBIE_IS_BABY);
a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL);
@@ -907,28 +907,64 @@ void cProtocol_1_12::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo
} // case mtZombieVillager
case mtBlaze:
+ case mtCaveSpider:
+ case mtElderGuardian:
case mtEnderDragon:
case mtGuardian:
case mtIronGolem:
case mtSnowGolem:
case mtSpider:
+ case mtWitherSkeleton:
{
// TODO: Mobs with extra fields that aren't implemented
break;
}
case mtMooshroom:
- case mtCaveSpider:
{
// Not mentioned on http://wiki.vg/Entities
break;
}
+ case mtCat:
+
+ case mtDonkey:
+ case mtMule:
+
+ case mtEndermite:
+
+ case mtEvoker:
+
+ case mtHusk:
+
+ case mtIllusioner:
+
+ case mtLlama:
+
+ case mtParrot:
+
+ case mtPolarBear:
+
+ case mtShulker:
+
+ case mtSkeletonHorse:
+ case mtZombieHorse:
+
+ case mtStray:
+
+ case mtVex:
+
+ case mtVindicator:
+ {
+ // Todo: Mobs not added yet. Grouped ones have the same metadata
+ UNREACHABLE("cProtocol_1_12::WriteMobMetadata: received unimplemented type");
+ break;
+ }
+
case mtGiant:
case mtSilverfish:
case mtSkeleton:
case mtSquid:
- case mtWitherSkeleton:
{
// Mobs with no extra fields
break;
@@ -936,9 +972,9 @@ void cProtocol_1_12::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo
case mtInvalidType:
{
- ASSERT(!"cProtocol_1_12::WriteMobMetadata: Recieved mob of invalid type");
break;
}
+ default: UNREACHABLE("cProtocol_1_12::WriteMobMetadata: received mob of invalid type");
} // switch (a_Mob.GetType())
}
@@ -1035,6 +1071,20 @@ cProtocol::Version cProtocol_1_12::GetProtocolVersion()
+UInt32 cProtocol_1_12::GetProtocolMobType(const eMonsterType a_MobType)
+{
+ switch (a_MobType)
+ {
+ case mtIllusioner: return 37;
+ case mtParrot: return 105;
+ default: return Super::GetProtocolMobType(a_MobType);
+ }
+}
+
+
+
+
+
bool cProtocol_1_12::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
{
switch (m_State)
diff --git a/src/Protocol/Protocol_1_12.h b/src/Protocol/Protocol_1_12.h
index 757ea9cc0..24e0eca60 100644
--- a/src/Protocol/Protocol_1_12.h
+++ b/src/Protocol/Protocol_1_12.h
@@ -36,6 +36,7 @@ protected:
virtual UInt32 GetPacketID(ePacketType a_Packet) override;
virtual Version GetProtocolVersion() override;
+ virtual UInt32 GetProtocolMobType(eMonsterType a_MobType) override;
virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) override;
virtual void HandlePacketAdvancementTab(cByteBuffer & a_ByteBuffer);
virtual void HandleCraftRecipe(cByteBuffer & a_ByteBuffer);
diff --git a/src/Protocol/Protocol_1_13.cpp b/src/Protocol/Protocol_1_13.cpp
index a61c094f4..9497012e3 100644
--- a/src/Protocol/Protocol_1_13.cpp
+++ b/src/Protocol/Protocol_1_13.cpp
@@ -406,38 +406,65 @@ UInt32 cProtocol_1_13::GetProtocolMobType(eMonsterType a_MobType)
// Map invalid type to Giant for easy debugging (if this ever spawns, something has gone very wrong)
case mtInvalidType: return 27;
case mtBat: return 3;
+ case mtCat: return 48;
case mtBlaze: return 4;
case mtCaveSpider: return 6;
case mtChicken: return 7;
+ case mtCod: return 8;
case mtCow: return 9;
case mtCreeper: return 10;
+ case mtDonkey: return 11;
+ case mtDolphin: return 12;
+ case mtDrowned: return 14;
+ case mtElderGuardian: return 15;
case mtEnderDragon: return 17;
case mtEnderman: return 18;
+ case mtEndermite: return 19;
+ case mtEvoker: return 21;
case mtGhast: return 26;
case mtGiant: return 27;
case mtGuardian: return 28;
case mtHorse: return 29;
+ case mtHusk: return 30;
+ case mtIllusioner: return 31;
case mtIronGolem: return 80;
+ case mtLlama: return 36;
case mtMagmaCube: return 38;
+ case mtMule: return 46;
case mtMooshroom: return 47;
case mtOcelot: return 48;
+ case mtParrot: return 50;
+ case mtPhantom: return 90;
case mtPig: return 51;
+ case mtPufferfish: return 52;
+ case mtPolarBear: return 54;
case mtRabbit: return 56;
+ case mtSalmon: return 57;
case mtSheep: return 58;
+ case mtShulker: return 59;
case mtSilverfish: return 61;
case mtSkeleton: return 62;
+ case mtSkeletonHorse: return 63;
case mtSlime: return 64;
case mtSnowGolem: return 66;
case mtSpider: return 69;
case mtSquid: return 70;
+ case mtStray: return 71;
+ case mtTropicalFish: return 72;
+ case mtTurtle: return 73;
+ case mtVex: return 78;
case mtVillager: return 79;
+ case mtVindicator: return 81;
case mtWitch: return 82;
case mtWither: return 83;
case mtWitherSkeleton: return 84;
case mtWolf: return 86;
case mtZombie: return 87;
case mtZombiePigman: return 53;
+ case mtZombieHorse: return 88;
case mtZombieVillager: return 89;
+
+ default: return 0;
}
UNREACHABLE("Unsupported mob type");
}
@@ -1222,7 +1249,6 @@ void cProtocol_1_13::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo
case mtBlaze:
case mtEnderDragon:
- case mtGuardian:
case mtIronGolem:
case mtSnowGolem:
case mtSpider:
@@ -1232,6 +1258,62 @@ void cProtocol_1_13::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo
break;
}
+ case mtCat:
+
+ case mtCod:
+
+ case mtDolphin:
+
+ case mtDonkey:
+
+ case mtDrowned:
+
+ case mtElderGuardian:
+ case mtGuardian:
+
+ case mtEndermite:
+
+ case mtEvoker:
+
+ case mtIllusioner:
+
+ case mtLlama:
+
+ case mtMule:
+
+ case mtParrot:
+
+ case mtPhantom:
+
+ case mtPolarBear:
+
+ case mtPufferfish:
+
+ case mtSalmon:
+
+ case mtShulker:
+
+ case mtStray:
+
+ case mtSkeletonHorse:
+ case mtZombieHorse:
+
+ case mtTropicalFish:
+
+ case mtTurtle:
+
+ case mtVex:
+
+ case mtVindicator:
+
+ case mtHusk:
+
+ {
+ // Todo: Mobs not added yet. Grouped ones have the same metadata
+ UNREACHABLE("cProtocol_1_13::WriteMobMetadata: received unimplemented type");
+ break;
+ }
+
case mtMooshroom:
case mtCaveSpider:
{
@@ -1251,9 +1333,9 @@ void cProtocol_1_13::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo
case mtInvalidType:
{
- ASSERT(!"cProtocol_1_13::WriteMobMetadata: Recieved mob of invalid type");
break;
}
+ default: UNREACHABLE("cProtocol_1_13::WriteMobMetadata: received mob of invalid type");
} // switch (a_Mob.GetType())
}
diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp
index 5856a87d2..acfa676b5 100644
--- a/src/Protocol/Protocol_1_8.cpp
+++ b/src/Protocol/Protocol_1_8.cpp
@@ -1388,9 +1388,17 @@ void cProtocol_1_8_0::SendSpawnMob(const cMonster & a_Mob)
{
ASSERT(m_State == 3); // In game mode?
+ const auto MobType = GetProtocolMobType(a_Mob.GetMobType());
+
+ // If the type is not valid in this protocol bail out:
+ if (MobType == 0)
+ {
+ return;
+ }
+
cPacketizer Pkt(*this, pktSpawnMob);
Pkt.WriteVarInt32(a_Mob.GetUniqueID());
- Pkt.WriteBEUInt8(static_cast<Byte>(GetProtocolMobType(a_Mob.GetMobType())));
+ Pkt.WriteBEUInt8(static_cast<Byte>(MobType));
Vector3d LastSentPos = a_Mob.GetLastSentPosition();
Pkt.WriteFPInt(LastSentPos.x);
Pkt.WriteFPInt(LastSentPos.y);
@@ -1876,7 +1884,7 @@ int cProtocol_1_8_0::GetParticleID(const AString & a_ParticleName)
-UInt32 cProtocol_1_8_0::GetProtocolMobType(eMonsterType a_MobType)
+UInt32 cProtocol_1_8_0::GetProtocolMobType(const eMonsterType a_MobType)
{
switch (a_MobType)
{
@@ -1890,6 +1898,7 @@ UInt32 cProtocol_1_8_0::GetProtocolMobType(eMonsterType a_MobType)
case mtCreeper: return 50;
case mtEnderDragon: return 63;
case mtEnderman: return 58;
+ case mtEndermite: return 67;
case mtGhast: return 56;
case mtGiant: return 53;
case mtGuardian: return 68;
@@ -1915,8 +1924,18 @@ UInt32 cProtocol_1_8_0::GetProtocolMobType(eMonsterType a_MobType)
case mtZombie: return 54;
case mtZombiePigman: return 57;
case mtZombieVillager: return 27;
+
+ // Mobs that get replaced with another because they were added later
+ case mtCat: return GetProtocolMobType(mtOcelot);
+ case mtDonkey: return GetProtocolMobType(mtHorse);
+ case mtMule: return GetProtocolMobType(mtHorse);
+ case mtSkeletonHorse: return GetProtocolMobType(mtHorse);
+ case mtZombieHorse: return GetProtocolMobType(mtHorse);
+ case mtStray: return GetProtocolMobType(mtSkeleton);
+ case mtHusk: return GetProtocolMobType(mtZombie);
+
+ default: return 0;
}
- UNREACHABLE("Unsupported mob type");
}
@@ -3792,6 +3811,14 @@ void cProtocol_1_8_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_M
break;
} // case mtSlime
+ case mtSkeleton:
+ case mtStray:
+ {
+ a_Pkt.WriteBEUInt8(0x0d);
+ a_Pkt.WriteBEUInt8(0); // Is normal skeleton
+ break;
+ }
+
case mtVillager:
{
auto & Villager = static_cast<const cVillager &>(a_Mob);
@@ -3857,6 +3884,7 @@ void cProtocol_1_8_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_M
break;
} // case mtWolf
+ case mtHusk:
case mtZombie:
{
auto & Zombie = static_cast<const cZombie &>(a_Mob);
@@ -3889,7 +3917,46 @@ void cProtocol_1_8_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_M
break;
} // case mtZombieVillager
- default: break;
+ case mtBlaze:
+ case mtElderGuardian:
+ case mtGuardian:
+ {
+ // TODO: Mobs with extra fields that aren't implemented
+ break;
+ }
+
+ case mtCat:
+
+ case mtEndermite:
+
+ case mtDonkey:
+ case mtMule:
+ case mtSkeletonHorse:
+ case mtZombieHorse:
+ {
+ // Todo: Mobs not added yet. Grouped ones have the same metadata
+ UNREACHABLE("cProtocol_1_8::WriteMobMetadata: received unimplemented type");
+ break;
+ }
+
+ case mtCaveSpider:
+ case mtEnderDragon:
+ case mtGiant:
+ case mtIronGolem:
+ case mtMooshroom:
+ case mtSilverfish:
+ case mtSnowGolem:
+ case mtSpider:
+ case mtSquid:
+ {
+ // Allowed mobs without additional metadata
+ break;
+ }
+ case mtInvalidType:
+ {
+ break;
+ }
+ default: UNREACHABLE("cProtocol_1_8::WriteMobMetadata: received mob of invalid type");
} // switch (a_Mob.GetType())
}
diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp
index eff9c8530..72d3fd4b1 100644
--- a/src/Protocol/Protocol_1_9.cpp
+++ b/src/Protocol/Protocol_1_9.cpp
@@ -418,12 +418,20 @@ void cProtocol_1_9_0::SendSpawnMob(const cMonster & a_Mob)
{
ASSERT(m_State == 3); // In game mode?
+ const auto MobType = GetProtocolMobType(a_Mob.GetMobType());
+
+ // If the type is not valid in this protocol bail out:
+ if (MobType == 0)
+ {
+ return;
+ }
+
cPacketizer Pkt(*this, pktSpawnMob);
Pkt.WriteVarInt32(a_Mob.GetUniqueID());
// TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now.
Pkt.WriteBEUInt64(0);
Pkt.WriteBEUInt64(a_Mob.GetUniqueID());
- Pkt.WriteBEUInt8(static_cast<Byte>(GetProtocolMobType(a_Mob.GetMobType())));
+ Pkt.WriteBEUInt8(static_cast<Byte>(MobType));
Vector3d LastSentPos = a_Mob.GetLastSentPosition();
Pkt.WriteBEDouble(LastSentPos.x);
Pkt.WriteBEDouble(LastSentPos.y);
@@ -572,6 +580,19 @@ cProtocol::Version cProtocol_1_9_0::GetProtocolVersion()
+UInt32 cProtocol_1_9_0::GetProtocolMobType(const eMonsterType a_MobType)
+{
+ switch (a_MobType)
+ {
+ case mtShulker: return 69;
+ default: return Super::GetProtocolMobType(a_MobType);
+ }
+}
+
+
+
+
+
bool cProtocol_1_9_0::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
{
switch (m_State)
@@ -1756,7 +1777,7 @@ void cProtocol_1_9_0::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a
void cProtocol_1_9_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
{
- // Living Enitiy Metadata
+ // Living entity metadata
if (a_Mob.HasCustomName())
{
// TODO: As of 1.9 _all_ entities can have custom names; should this be moved up?
@@ -1966,6 +1987,13 @@ void cProtocol_1_9_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_M
break;
} // case mtSheep
+ case mtSkeleton:
+ {
+ a_Pkt.WriteBEUInt8(11);
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT);
+ a_Pkt.WriteVarInt32(0);
+ }
+
case mtSlime:
{
auto & Slime = static_cast<const cSlime &>(a_Mob);
@@ -2097,7 +2125,52 @@ void cProtocol_1_9_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_M
break;
} // case mtZombieVillager
- default: break;
+ case mtBlaze:
+ case mtElderGuardian:
+ case mtGuardian:
+ {
+ // TODO: Mobs with extra fields that aren't implemented
+ break;
+ }
+
+ case mtCat:
+
+ case mtDonkey:
+
+ case mtEndermite:
+
+ case mtMule:
+
+ case mtStray:
+
+ case mtSkeletonHorse:
+ case mtZombieHorse:
+
+ case mtShulker:
+ {
+ // Todo: Mobs not added yet. Grouped ones have the same metadata
+ UNREACHABLE("cProtocol_1_9::WriteMobMetadata: received unimplemented type");
+ break;
+ }
+
+ case mtCaveSpider:
+ case mtEnderDragon:
+ case mtGiant:
+ case mtIronGolem:
+ case mtMooshroom:
+ case mtSilverfish:
+ case mtSnowGolem:
+ case mtSpider:
+ case mtSquid:
+ {
+ // Entities without additional metadata
+ break;
+ }
+ case mtInvalidType:
+ {
+
+ }
+ default: UNREACHABLE("cProtocol_1_9::WriteMobMetadata: received mob of invalid type");
} // switch (a_Mob.GetType())
}
diff --git a/src/Protocol/Protocol_1_9.h b/src/Protocol/Protocol_1_9.h
index a180c8f5e..0339ddeb3 100644
--- a/src/Protocol/Protocol_1_9.h
+++ b/src/Protocol/Protocol_1_9.h
@@ -72,6 +72,9 @@ protected:
/** Returns 1.9. */
virtual Version GetProtocolVersion() override;
+ /** Converts eMonsterType to protocol-specific mob types */
+ virtual UInt32 GetProtocolMobType(eMonsterType a_MobType) override;
+
/** Reads and handles the packet. The packet length and type have already been read.
Returns true if the packet was understood, false if it was an unknown packet. */
virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) override;