summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Protocol/Packetizer.cpp1
-rw-r--r--src/Protocol/Protocol.h7
-rw-r--r--src/Protocol/Protocol_1_10.h2
-rw-r--r--src/Protocol/Protocol_1_11.h4
-rw-r--r--src/Protocol/Protocol_1_12.h6
-rw-r--r--src/Protocol/Protocol_1_13.cpp90
-rw-r--r--src/Protocol/Protocol_1_13.h7
-rw-r--r--src/Protocol/Protocol_1_14.h2
-rw-r--r--src/Protocol/Protocol_1_8.cpp109
-rw-r--r--src/Protocol/Protocol_1_8.h8
-rw-r--r--src/Protocol/Protocol_1_9.cpp167
-rw-r--r--src/Protocol/Protocol_1_9.h12
12 files changed, 380 insertions, 35 deletions
diff --git a/src/Protocol/Packetizer.cpp b/src/Protocol/Packetizer.cpp
index 9f0fd28b1..e71cba086 100644
--- a/src/Protocol/Packetizer.cpp
+++ b/src/Protocol/Packetizer.cpp
@@ -62,6 +62,7 @@ AString cPacketizer::PacketTypeToStr(cProtocol::ePacketType a_PacketType)
case cProtocol::pktBlockBreakAnim: return "pktBlockBreakAnim";
case cProtocol::pktBlockChange: return "pktBlockChange";
case cProtocol::pktBlockChanges: return "pktBlockChanges";
+ case cProtocol::pktBossBar: return "pktBossBar";
case cProtocol::pktCameraSetTo: return "pktCameraSetTo";
case cProtocol::pktChatRaw: return "pktChatRaw";
case cProtocol::pktCollectEntity: return "pktCollectEntity";
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index 7b5ad7a51..41c461e76 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -67,6 +67,7 @@ public:
pktBlockBreakAnim,
pktBlockChange,
pktBlockChanges,
+ pktBossBar,
pktCameraSetTo,
pktChatRaw,
pktCollectEntity,
@@ -362,6 +363,12 @@ public:
virtual void SendBlockBreakAnim (UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) = 0;
virtual void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
virtual void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) = 0;
+ virtual void 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) = 0;
+ virtual void SendBossBarRemove (UInt32 a_UniqueID) = 0;
+ virtual void SendBossBarUpdateHealth (UInt32 a_UniqueID, float a_FractionFilled) = 0;
+ virtual void SendBossBarUpdateFlags (UInt32 a_UniqueID, bool a_DarkenSky, bool a_PlayEndMusic, bool a_CreateFog) = 0;
+ virtual void SendBossBarUpdateStyle (UInt32 a_UniqueID, BossBarColor a_Color, BossBarDivisionType a_DivisionType) = 0;
+ virtual void SendBossBarUpdateTitle (UInt32 a_UniqueID, const cCompositeChat & a_Title) = 0;
virtual void SendCameraSetTo (const cEntity & a_Entity) = 0;
virtual void SendChat (const AString & a_Message, eChatType a_Type) = 0;
virtual void SendChat (const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) = 0;
diff --git a/src/Protocol/Protocol_1_10.h b/src/Protocol/Protocol_1_10.h
index 3d78e7079..6c27b25b5 100644
--- a/src/Protocol/Protocol_1_10.h
+++ b/src/Protocol/Protocol_1_10.h
@@ -26,7 +26,7 @@ class cProtocol_1_10_0:
public:
- using Super::cProtocol_1_9_4;
+ using Super::Super;
protected:
diff --git a/src/Protocol/Protocol_1_11.h b/src/Protocol/Protocol_1_11.h
index 4c0d8a22a..731426396 100644
--- a/src/Protocol/Protocol_1_11.h
+++ b/src/Protocol/Protocol_1_11.h
@@ -28,7 +28,7 @@ class cProtocol_1_11_0:
public:
- using Super::cProtocol_1_10_0;
+ using Super::Super;
protected:
@@ -62,7 +62,7 @@ class cProtocol_1_11_1:
public:
- using Super::cProtocol_1_11_0;
+ using Super::Super;
protected:
diff --git a/src/Protocol/Protocol_1_12.h b/src/Protocol/Protocol_1_12.h
index 24e0eca60..7a92c156f 100644
--- a/src/Protocol/Protocol_1_12.h
+++ b/src/Protocol/Protocol_1_12.h
@@ -30,7 +30,7 @@ class cProtocol_1_12:
public:
- using Super::cProtocol_1_11_1;
+ using Super::Super;
protected:
@@ -56,7 +56,7 @@ class cProtocol_1_12_1:
public:
- using Super::cProtocol_1_12;
+ using Super::Super;
protected:
@@ -76,7 +76,7 @@ class cProtocol_1_12_2:
public:
- using Super::cProtocol_1_12_1;
+ using Super::Super;
protected:
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;
diff --git a/src/Protocol/Protocol_1_13.h b/src/Protocol/Protocol_1_13.h
index 483ee88a0..d515306e3 100644
--- a/src/Protocol/Protocol_1_13.h
+++ b/src/Protocol/Protocol_1_13.h
@@ -32,7 +32,7 @@ class cProtocol_1_13:
public:
- using Super::cProtocol_1_12_2;
+ using Super::Super;
protected:
@@ -84,10 +84,13 @@ class cProtocol_1_13_1 :
public:
- using Super::cProtocol_1_13;
+ using Super::Super;
protected:
+ virtual void 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) override;
+ virtual void SendBossBarUpdateFlags(UInt32 a_UniqueID, bool a_DarkenSky, bool a_PlayEndMusic, bool a_CreateFog) override;
+
virtual Version GetProtocolVersion() override;
virtual std::pair<short, short> GetItemFromProtocolID(UInt32 a_ProtocolID) override;
virtual UInt32 GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) override;
diff --git a/src/Protocol/Protocol_1_14.h b/src/Protocol/Protocol_1_14.h
index e9bbca6eb..3f328bbac 100644
--- a/src/Protocol/Protocol_1_14.h
+++ b/src/Protocol/Protocol_1_14.h
@@ -26,7 +26,7 @@ class cProtocol_1_14:
public:
- using Super::cProtocol_1_13_2;
+ using Super::Super;
protected:
diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp
index 91c132c8b..e3bb7e5a3 100644
--- a/src/Protocol/Protocol_1_8.cpp
+++ b/src/Protocol/Protocol_1_8.cpp
@@ -280,6 +280,60 @@ void cProtocol_1_8_0::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlo
+void cProtocol_1_8_0::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)
+{
+ // No such packet here
+}
+
+
+
+
+
+void cProtocol_1_8_0::SendBossBarRemove(UInt32 a_UniqueID)
+{
+ // No such packet here
+}
+
+
+
+
+
+void cProtocol_1_8_0::SendBossBarUpdateFlags(UInt32 a_UniqueID, bool a_DarkenSky, bool a_PlayEndMusic, bool a_CreateFog)
+{
+ // No such packet here
+}
+
+
+
+
+
+void cProtocol_1_8_0::SendBossBarUpdateHealth(UInt32 a_UniqueID, float a_FractionFilled)
+{
+ // No such packet here
+}
+
+
+
+
+
+void cProtocol_1_8_0::SendBossBarUpdateStyle(UInt32 a_UniqueID, BossBarColor a_Color, BossBarDivisionType a_DivisionType)
+{
+ // No such packet here
+}
+
+
+
+
+
+void cProtocol_1_8_0::SendBossBarUpdateTitle(UInt32 a_UniqueID, const cCompositeChat & a_Title)
+{
+ // No such packet here
+}
+
+
+
+
+
void cProtocol_1_8_0::SendCameraSetTo(const cEntity & a_Entity)
{
cPacketizer Pkt(*this, pktCameraSetTo);
@@ -356,9 +410,22 @@ void cProtocol_1_8_0::SendDestroyEntity(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
- cPacketizer Pkt(*this, pktDestroyEntity);
- Pkt.WriteVarInt32(1);
- Pkt.WriteVarInt32(a_Entity.GetUniqueID());
+ {
+ cPacketizer Pkt(*this, pktDestroyEntity);
+ Pkt.WriteVarInt32(1);
+ Pkt.WriteVarInt32(a_Entity.GetUniqueID());
+ }
+
+ if (!a_Entity.IsMob())
+ {
+ return;
+ }
+
+ const auto & Mob = static_cast<const cMonster &>(a_Entity);
+ if ((Mob.GetMobType() == mtEnderDragon) || (Mob.GetMobType() == mtWither))
+ {
+ SendBossBarRemove(Mob.GetUniqueID());
+ }
}
@@ -1021,54 +1088,54 @@ void cProtocol_1_8_0::SendPlayerListRemovePlayer(const cPlayer & a_Player)
-void cProtocol_1_8_0::SendPlayerListUpdateGameMode(const cPlayer & a_Player)
+void cProtocol_1_8_0::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, pktPlayerList);
- Pkt.WriteVarInt32(1);
+ Pkt.WriteVarInt32(3);
Pkt.WriteVarInt32(1);
Pkt.WriteUUID(a_Player.GetUUID());
- Pkt.WriteVarInt32(static_cast<UInt32>(a_Player.GetEffectiveGameMode()));
+
+ if (a_CustomName.empty())
+ {
+ Pkt.WriteBool(false);
+ }
+ else
+ {
+ Pkt.WriteBool(true);
+ Pkt.WriteString(Printf("{\"text\":\"%s\"}", a_CustomName.c_str()));
+ }
}
-void cProtocol_1_8_0::SendPlayerListUpdatePing(const cPlayer & a_Player)
+void cProtocol_1_8_0::SendPlayerListUpdateGameMode(const cPlayer & a_Player)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, pktPlayerList);
- Pkt.WriteVarInt32(2);
+ Pkt.WriteVarInt32(1);
Pkt.WriteVarInt32(1);
Pkt.WriteUUID(a_Player.GetUUID());
- Pkt.WriteVarInt32(static_cast<UInt32>(a_Player.GetClientHandle()->GetPing()));
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_Player.GetEffectiveGameMode()));
}
-void cProtocol_1_8_0::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName)
+void cProtocol_1_8_0::SendPlayerListUpdatePing(const cPlayer & a_Player)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, pktPlayerList);
- Pkt.WriteVarInt32(3);
+ Pkt.WriteVarInt32(2);
Pkt.WriteVarInt32(1);
Pkt.WriteUUID(a_Player.GetUUID());
-
- if (a_CustomName.empty())
- {
- Pkt.WriteBool(false);
- }
- else
- {
- Pkt.WriteBool(true);
- Pkt.WriteString(Printf("{\"text\":\"%s\"}", a_CustomName.c_str()));
- }
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_Player.GetClientHandle()->GetPing()));
}
diff --git a/src/Protocol/Protocol_1_8.h b/src/Protocol/Protocol_1_8.h
index 4e4f2fa47..e2aadf147 100644
--- a/src/Protocol/Protocol_1_8.h
+++ b/src/Protocol/Protocol_1_8.h
@@ -45,6 +45,12 @@ public:
virtual void SendBlockBreakAnim (UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) override;
virtual void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
virtual void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) override;
+ virtual void 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) override;
+ virtual void SendBossBarRemove (UInt32 a_UniqueID) override;
+ virtual void SendBossBarUpdateFlags (UInt32 a_UniqueID, bool a_DarkenSky, bool a_PlayEndMusic, bool a_CreateFog) override;
+ virtual void SendBossBarUpdateHealth (UInt32 a_UniqueID, float a_FractionFilled) override;
+ virtual void SendBossBarUpdateStyle (UInt32 a_UniqueID, BossBarColor a_Color, BossBarDivisionType a_DivisionType) override;
+ virtual void SendBossBarUpdateTitle (UInt32 a_UniqueID, const cCompositeChat & a_Title) override;
virtual void SendCameraSetTo (const cEntity & a_Entity) override;
virtual void SendChat (const AString & a_Message, eChatType a_Type) override;
virtual void SendChat (const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) override;
@@ -85,9 +91,9 @@ public:
virtual void SendPlayerListAddPlayer (const cPlayer & a_Player) override;
virtual void SendPlayerListHeaderFooter (const cCompositeChat & a_Header, const cCompositeChat & a_Footer) override;
virtual void SendPlayerListRemovePlayer (const cPlayer & a_Player) override;
+ virtual void SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName) override;
virtual void SendPlayerListUpdateGameMode (const cPlayer & a_Player) override;
virtual void SendPlayerListUpdatePing (const cPlayer & a_Player) override;
- virtual void SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName) override;
virtual void SendPlayerMaxSpeed (void) override;
virtual void SendPlayerMoveLook (void) override;
virtual void SendPlayerPosition (void) override;
diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp
index 5506aec1a..88f8933be 100644
--- a/src/Protocol/Protocol_1_9.cpp
+++ b/src/Protocol/Protocol_1_9.cpp
@@ -104,6 +104,172 @@ void cProtocol_1_9_0::SendAttachEntity(const cEntity & a_Entity, const cEntity &
+void cProtocol_1_9_0::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 || a_CreateFog)
+ {
+ Flags |= 0x02;
+ }
+ Pkt.WriteBEUInt8(Flags);
+ }
+}
+
+
+
+
+
+void cProtocol_1_9_0::SendBossBarRemove(UInt32 a_UniqueID)
+{
+ 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(1); // Remove
+}
+
+
+
+
+
+void cProtocol_1_9_0::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 || a_CreateFog)
+ {
+ Flags |= 0x02;
+ }
+ Pkt.WriteBEUInt8(Flags);
+ }
+}
+
+
+
+
+
+void cProtocol_1_9_0::SendBossBarUpdateHealth(UInt32 a_UniqueID, float a_FractionFilled)
+{
+ 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(2); // Update health
+ Pkt.WriteBEFloat(a_FractionFilled);
+}
+
+
+
+
+
+void cProtocol_1_9_0::SendBossBarUpdateStyle(UInt32 a_UniqueID, BossBarColor a_Color, BossBarDivisionType a_DivisionType)
+{
+ 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(4); // Update health
+ 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;
+ }
+ }());
+}
+
+
+
+
+
+void cProtocol_1_9_0::SendBossBarUpdateTitle(UInt32 a_UniqueID, const cCompositeChat & a_Title)
+{
+ 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(3); // Update title
+ Pkt.WriteString(a_Title.CreateJsonString());
+}
+
+
+
+
+
void cProtocol_1_9_0::SendDetachEntity(const cEntity & a_Entity, const cEntity & a_PreviousVehicle)
{
ASSERT(m_State == 3); // In game mode?
@@ -488,6 +654,7 @@ UInt32 cProtocol_1_9_0::GetPacketID(cProtocol::ePacketType a_Packet)
case pktBlockBreakAnim: return 0x08;
case pktBlockChange: return 0x0b;
case pktBlockChanges: return 0x10;
+ case pktBossBar: return 0x0c;
case pktCameraSetTo: return 0x36;
case pktChatRaw: return 0x0f;
case pktCollectEntity: return 0x49;
diff --git a/src/Protocol/Protocol_1_9.h b/src/Protocol/Protocol_1_9.h
index 27b005bd4..cdaeaeed9 100644
--- a/src/Protocol/Protocol_1_9.h
+++ b/src/Protocol/Protocol_1_9.h
@@ -41,6 +41,12 @@ public:
/** Sending stuff to clients (alphabetically sorted): */
virtual void SendAttachEntity (const cEntity & a_Entity, const cEntity & a_Vehicle) override;
+ virtual void 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) override;
+ virtual void SendBossBarRemove (UInt32 a_UniqueID) override;
+ virtual void SendBossBarUpdateFlags (UInt32 a_UniqueID, bool a_DarkenSky, bool a_PlayEndMusic, bool a_CreateFog) override;
+ virtual void SendBossBarUpdateHealth (UInt32 a_UniqueID, float a_FractionFilled) override;
+ virtual void SendBossBarUpdateStyle (UInt32 a_UniqueID, BossBarColor a_Color, BossBarDivisionType a_DivisionType) override;
+ virtual void SendBossBarUpdateTitle (UInt32 a_UniqueID, const cCompositeChat & a_Title) override;
virtual void SendDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle) override;
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
virtual void SendEntityMetadata (const cEntity & a_Entity) override;
@@ -153,7 +159,7 @@ class cProtocol_1_9_1:
public:
- using Super::cProtocol_1_9_0;
+ using Super::Super;
protected:
@@ -175,7 +181,7 @@ class cProtocol_1_9_2:
public:
- using Super::cProtocol_1_9_1;
+ using Super::Super;
protected:
@@ -195,7 +201,7 @@ class cProtocol_1_9_4:
public:
- using Super::cProtocol_1_9_2;
+ using Super::Super;
protected: