diff options
Diffstat (limited to 'src/Protocol/Protocol18x.cpp')
-rw-r--r-- | src/Protocol/Protocol18x.cpp | 122 |
1 files changed, 63 insertions, 59 deletions
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp index c435f6e40..98b22add1 100644 --- a/src/Protocol/Protocol18x.cpp +++ b/src/Protocol/Protocol18x.cpp @@ -715,60 +715,31 @@ void cProtocol180::SendPaintingSpawn(const cPainting & a_Painting) -void cProtocol180::SendMapColumn(int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale) +void cProtocol180::SendMapData(const cMap & a_Map, int a_DataStartX, int a_DataStartY) { ASSERT(m_State == 3); // In game mode? cPacketizer Pkt(*this, 0x34); - Pkt.WriteVarInt32(a_ID); - Pkt.WriteBEUInt8(m_Scale); + Pkt.WriteVarInt32(a_Map.GetID()); + Pkt.WriteBEUInt8(a_Map.GetScale()); - Pkt.WriteVarInt32(0); - Pkt.WriteBEUInt8(1); - Pkt.WriteBEUInt8(a_Length); - Pkt.WriteBEUInt8(a_X); - Pkt.WriteBEUInt8(a_Y); - - Pkt.WriteVarInt32(a_Length); - for (unsigned int i = 0; i < a_Length; ++i) + Pkt.WriteVarInt32(static_cast<UInt32>(a_Map.GetDecorators().size())); + for (const auto Decorator : a_Map.GetDecorators()) { - Pkt.WriteBEUInt8(a_Colors[i]); + Pkt.WriteBEUInt8(static_cast<Byte>((static_cast<int>(Decorator.GetType()) << 4) | (Decorator.GetRot() & 0xF))); + Pkt.WriteBEUInt8(Decorator.GetPixelX()); + Pkt.WriteBEUInt8(Decorator.GetPixelZ()); } -} - - - - - -void cProtocol180::SendMapDecorators(int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale) -{ - ASSERT(m_State == 3); // In game mode? - - cPacketizer Pkt(*this, 0x34); - Pkt.WriteVarInt32(a_ID); - Pkt.WriteBEUInt8(m_Scale); - Pkt.WriteVarInt32(static_cast<UInt32>(a_Decorators.size())); - for (cMapDecoratorList::const_iterator it = a_Decorators.begin(); it != a_Decorators.end(); ++it) + Pkt.WriteBEUInt8(128); + Pkt.WriteBEUInt8(128); + Pkt.WriteBEUInt8(a_DataStartX); + Pkt.WriteBEUInt8(a_DataStartY); + Pkt.WriteVarInt32(static_cast<UInt32>(a_Map.GetData().size())); + for (auto itr = a_Map.GetData().cbegin(); itr != a_Map.GetData().cend(); ++itr) { - Pkt.WriteBEUInt8((it->GetType() << 4) | (it->GetRot() & 0xf)); - Pkt.WriteBEUInt8(it->GetPixelX()); - Pkt.WriteBEUInt8(it->GetPixelZ()); + Pkt.WriteBEUInt8(*itr); } - - Pkt.WriteBEUInt8(0); -} - - - - - -void cProtocol180::SendMapInfo(int a_ID, unsigned int a_Scale) -{ - UNUSED(a_ID); - UNUSED(a_Scale); - - // This packet was removed in 1.8 } @@ -3351,7 +3322,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) a_Pkt.WriteBEUInt8(Bat.IsHanging() ? 1 : 0); break; } // case mtBat - + case mtCreeper: { auto & Creeper = reinterpret_cast<const cCreeper &>(a_Mob); @@ -3361,7 +3332,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) a_Pkt.WriteBEUInt8(Creeper.IsCharged() ? 1 : 0); break; } // case mtCreeper - + case mtEnderman: { auto & Enderman = reinterpret_cast<const cEnderman &>(a_Mob); @@ -3373,7 +3344,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) a_Pkt.WriteBEUInt8(Enderman.IsScreaming() ? 1 : 0); break; } // case mtEnderman - + case mtGhast: { auto & Ghast = reinterpret_cast<const cGhast &>(a_Mob); @@ -3381,7 +3352,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) a_Pkt.WriteBEUInt8(Ghast.IsCharging()); break; } // case mtGhast - + case mtHorse: { auto & Horse = reinterpret_cast<const cHorse &>(a_Mob); @@ -3398,10 +3369,6 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) { Flags |= 0x08; } - if (Horse.IsBaby()) - { - Flags |= 0x10; - } if (Horse.IsEating()) { Flags |= 0x20; @@ -3425,6 +3392,9 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) a_Pkt.WriteBEInt32(Appearance); a_Pkt.WriteBEUInt8(0x56); // Int at index 22 a_Pkt.WriteBEInt32(Horse.GetHorseArmour()); + + a_Pkt.WriteBEUInt8(0x0c); + a_Pkt.WriteBEInt8(Horse.GetAge()); break; } // case mtHorse @@ -3436,17 +3406,38 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) break; } // case mtMagmaCube + case mtOcelot: + { + auto & Ocelot = reinterpret_cast<const cOcelot &>(a_Mob); + a_Pkt.WriteBEUInt8(0x0c); + a_Pkt.WriteBEInt8(Ocelot.GetAge()); + break; + } // case mtOcelot + case mtPig: { auto & Pig = reinterpret_cast<const cPig &>(a_Mob); + a_Pkt.WriteBEUInt8(0x0c); + a_Pkt.WriteBEInt8(Pig.GetAge()); a_Pkt.WriteBEUInt8(0x10); a_Pkt.WriteBEUInt8(Pig.IsSaddled() ? 1 : 0); break; } // case mtPig - + + case mtRabbit: + { + auto & Rabbit = reinterpret_cast<const cRabbit &>(a_Mob); + a_Pkt.WriteBEUInt8(0x0c); + a_Pkt.WriteBEInt8(Rabbit.GetAge()); + break; + } // case mtRabbit + case mtSheep: { auto & Sheep = reinterpret_cast<const cSheep &>(a_Mob); + a_Pkt.WriteBEUInt8(0x0c); + a_Pkt.WriteBEInt8(Sheep.GetAge()); + a_Pkt.WriteBEUInt8(0x10); Byte SheepMetadata = 0; SheepMetadata = Sheep.GetFurColor(); @@ -3457,7 +3448,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) a_Pkt.WriteBEUInt8(SheepMetadata); break; } // case mtSheep - + case mtSkeleton: { auto & Skeleton = reinterpret_cast<const cSkeleton &>(a_Mob); @@ -3465,7 +3456,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) a_Pkt.WriteBEUInt8(Skeleton.IsWither() ? 1 : 0); break; } // case mtSkeleton - + case mtSlime: { auto & Slime = reinterpret_cast<const cSlime &>(a_Mob); @@ -3479,9 +3470,11 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) auto & Villager = reinterpret_cast<const cVillager &>(a_Mob); a_Pkt.WriteBEUInt8(0x50); a_Pkt.WriteBEInt32(Villager.GetVilType()); + a_Pkt.WriteBEUInt8(0x0c); + a_Pkt.WriteBEInt8(Villager.GetAge()); break; } // case mtVillager - + case mtWitch: { auto & Witch = reinterpret_cast<const cWitch &>(a_Mob); @@ -3499,7 +3492,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) a_Pkt.WriteBEFloat(static_cast<float>(a_Mob.GetHealth())); break; } // case mtWither - + case mtWolf: { auto & Wolf = reinterpret_cast<const cWolf &>(a_Mob); @@ -3525,20 +3518,31 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) a_Pkt.WriteBEUInt8(Wolf.IsBegging() ? 1 : 0); a_Pkt.WriteBEUInt8(0x14); a_Pkt.WriteBEUInt8(Wolf.GetCollarColor()); + + a_Pkt.WriteBEUInt8(0x0c); + a_Pkt.WriteBEInt8(Wolf.GetAge()); break; } // case mtWolf - + case mtZombie: { auto & Zombie = reinterpret_cast<const cZombie &>(a_Mob); a_Pkt.WriteBEUInt8(0x0c); - a_Pkt.WriteBEUInt8(Zombie.IsBaby() ? 1 : 0); + a_Pkt.WriteBEInt8(Zombie.IsBaby() ? 1 : -1); a_Pkt.WriteBEUInt8(0x0d); a_Pkt.WriteBEUInt8(Zombie.IsVillagerZombie() ? 1 : 0); a_Pkt.WriteBEUInt8(0x0e); a_Pkt.WriteBEUInt8(Zombie.IsConverting() ? 1 : 0); break; } // case mtZombie + + case mtZombiePigman: + { + auto & ZombiePigman = reinterpret_cast<const cZombiePigman &>(a_Mob); + a_Pkt.WriteBEUInt8(0x0c); + a_Pkt.WriteBEInt8(ZombiePigman.IsBaby() ? 1 : -1); + break; + } // case mtZombiePigman } // switch (a_Mob.GetType()) } |