summaryrefslogtreecommitdiffstats
path: root/src/Protocol/Protocol_1_11.cpp
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/Protocol_1_11.cpp
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 '')
-rw-r--r--src/Protocol/Protocol_1_11.cpp91
1 files changed, 84 insertions, 7 deletions
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())
}