diff options
Diffstat (limited to '')
-rw-r--r-- | src/Protocol/Protocol_1_13.cpp | 90 |
1 files changed, 89 insertions, 1 deletions
diff --git a/src/Protocol/Protocol_1_13.cpp b/src/Protocol/Protocol_1_13.cpp index afb0a9cc9..77cf86333 100644 --- a/src/Protocol/Protocol_1_13.cpp +++ b/src/Protocol/Protocol_1_13.cpp @@ -23,6 +23,7 @@ Implements the 1.13 protocol classes: #include "../Mobs/IncludeAllMonsters.h" +#include "../CompositeChat.h" #include "../ClientHandle.h" #include "../Root.h" #include "../Server.h" @@ -465,7 +466,6 @@ UInt32 cProtocol_1_13::GetProtocolMobType(eMonsterType a_MobType) case mtZombieVillager: return 89; default: return 0; } - UNREACHABLE("Unsupported mob type"); } @@ -1338,6 +1338,94 @@ void cProtocol_1_13::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo //////////////////////////////////////////////////////////////////////////////// // cProtocol_1_13_1: +void cProtocol_1_13_1::SendBossBarAdd(UInt32 a_UniqueID, const cCompositeChat & a_Title, float a_FractionFilled, BossBarColor a_Color, BossBarDivisionType a_DivisionType, bool a_DarkenSky, bool a_PlayEndMusic, bool a_CreateFog) +{ + ASSERT(m_State == 3); // In game mode? + + cPacketizer Pkt(*this, pktBossBar); + // 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_UniqueID); + Pkt.WriteVarInt32(0); // Add + Pkt.WriteString(a_Title.CreateJsonString()); + Pkt.WriteBEFloat(a_FractionFilled); + Pkt.WriteVarInt32([a_Color] + { + switch (a_Color) + { + case BossBarColor::Pink: return 0U; + case BossBarColor::Blue: return 1U; + case BossBarColor::Red: return 2U; + case BossBarColor::Green: return 3U; + case BossBarColor::Yellow: return 4U; + case BossBarColor::Purple: return 5U; + case BossBarColor::White: return 6U; + } + }()); + Pkt.WriteVarInt32([a_DivisionType] + { + switch (a_DivisionType) + { + case BossBarDivisionType::None: return 0U; + case BossBarDivisionType::SixNotches: return 1U; + case BossBarDivisionType::TenNotches: return 2U; + case BossBarDivisionType::TwelveNotches: return 3U; + case BossBarDivisionType::TwentyNotches: return 4U; + } + }()); + { + UInt8 Flags = 0x00; + if (a_DarkenSky) + { + Flags |= 0x01; + } + if (a_PlayEndMusic) + { + Flags |= 0x02; + } + if (a_CreateFog) + { + Flags |= 0x04; // Only difference to 1.9 is fog now a separate flag + } + Pkt.WriteBEUInt8(Flags); + } +} + + + + + +void cProtocol_1_13_1::SendBossBarUpdateFlags(UInt32 a_UniqueID, bool a_DarkenSky, bool a_PlayEndMusic, bool a_CreateFog) +{ + ASSERT(m_State == 3); // In game mode? + + cPacketizer Pkt(*this, pktBossBar); + // 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_UniqueID); + Pkt.WriteVarInt32(5); // Update Flags + { + UInt8 Flags = 0x00; + if (a_DarkenSky) + { + Flags |= 0x01; + } + if (a_PlayEndMusic) + { + Flags |= 0x02; + } + if (a_CreateFog) + { + Flags |= 0x04; // Only difference to 1.9 is fog now a separate flag + } + Pkt.WriteBEUInt8(Flags); + } +} + + + + + cProtocol::Version cProtocol_1_13_1::GetProtocolVersion() { return Version::v1_13_1; |