diff options
author | 12xx12 <44411062+12xx12@users.noreply.github.com> | 2020-11-23 00:41:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-23 00:41:13 +0100 |
commit | e35519ec8ab1b958408ab2a90b88dffc1bcc7fb2 (patch) | |
tree | 3ed498478eabe7aa01b54f85d8ec9c2bc821fe66 /src/Protocol/Protocol_1_8.cpp | |
parent | Add coloured glass pane recipes (#5032) (diff) | |
download | cuberite-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/Protocol_1_8.cpp')
-rw-r--r-- | src/Protocol/Protocol_1_8.cpp | 75 |
1 files changed, 71 insertions, 4 deletions
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()) } |