Skip to content

Commit

Permalink
More 1.20.5 protocol fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adepierre committed May 2, 2024
1 parent 82c873f commit 30f32b9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
Expand Up @@ -66,7 +66,7 @@ namespace ProtocolCraft
}
#endif

#if PROTOCOL_VERSION > 759 /* > 1.19 */
#if PROTOCOL_VERSION > 759 /* > 1.19 */ && PROTOCOL_VERSION < 766 /* < 1.20.5 */
void SetEnforcesSecureChat(const bool enforces_secure_chat_)
{
enforces_secure_chat = enforces_secure_chat_;
Expand Down Expand Up @@ -103,7 +103,7 @@ namespace ProtocolCraft
}
#endif

#if PROTOCOL_VERSION > 759 /* > 1.19 */
#if PROTOCOL_VERSION > 759 /* > 1.19 */ && PROTOCOL_VERSION < 766 /* < 1.20.5 */
bool GetEnforcesSecureChat() const
{
return enforces_secure_chat;
Expand All @@ -129,7 +129,7 @@ namespace ProtocolCraft
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
previews_chat = ReadData<bool>(iter, length);
#endif
#if PROTOCOL_VERSION > 759 /* > 1.19 */
#if PROTOCOL_VERSION > 759 /* > 1.19 */ && PROTOCOL_VERSION < 766 /* < 1.20.5 */
enforces_secure_chat = ReadData<bool>(iter, length);
#endif
}
Expand All @@ -151,7 +151,7 @@ namespace ProtocolCraft
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
WriteData<bool>(previews_chat, container);
#endif
#if PROTOCOL_VERSION > 759 /* > 1.19 */
#if PROTOCOL_VERSION > 759 /* > 1.19 */ && PROTOCOL_VERSION < 766 /* < 1.20.5 */
WriteData<bool>(enforces_secure_chat, container);
#endif
}
Expand Down Expand Up @@ -179,7 +179,7 @@ namespace ProtocolCraft
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
output["previews_chat"] = previews_chat;
#endif
#if PROTOCOL_VERSION > 759 /* > 1.19 */
#if PROTOCOL_VERSION > 759 /* > 1.19 */ && PROTOCOL_VERSION < 766 /* < 1.20.5 */
output["enforces_secure_chat"] = enforces_secure_chat;
#endif

Expand All @@ -198,7 +198,7 @@ namespace ProtocolCraft
#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
bool previews_chat = false;
#endif
#if PROTOCOL_VERSION > 759 /* > 1.19 */
#if PROTOCOL_VERSION > 759 /* > 1.19 */ && PROTOCOL_VERSION < 766 /* < 1.20.5 */
bool enforces_secure_chat = false;
#endif

Expand Down
Expand Up @@ -42,6 +42,7 @@ namespace ProtocolCraft

}

#if PROTOCOL_VERSION < 766 /* < 1.20.5 */
void SetContainerId(const char container_id_)
{
container_id = container_id_;
Expand All @@ -51,8 +52,20 @@ namespace ProtocolCraft
{
button_id = button_id_;
}
#else
void SetContainerId(const int container_id_)
{
container_id = container_id_;
}

void SetButtonId(const int button_id_)
{
button_id = button_id_;
}
#endif


#if PROTOCOL_VERSION < 766 /* < 1.20.5 */
char GetContainerId() const
{
return container_id;
Expand All @@ -62,19 +75,40 @@ namespace ProtocolCraft
{
return button_id;
}
#else
int GetContainerId() const
{
return container_id;
}

int GetButtonId() const
{
return button_id;
}
#endif


protected:
virtual void ReadImpl(ReadIterator& iter, size_t& length) override
{
#if PROTOCOL_VERSION < 766 /* < 1.20.5 */
container_id = ReadData<char>(iter, length);
button_id = ReadData<char>(iter, length);
#else
container_id = ReadData<VarInt>(iter, length);
button_id = ReadData<VarInt>(iter, length);
#endif
}

virtual void WriteImpl(WriteContainer& container) const override
{
#if PROTOCOL_VERSION < 766 /* < 1.20.5 */
WriteData<char>(container_id, container);
WriteData<char>(button_id, container);
#else
WriteData<VarInt>(container_id, container);
WriteData<VarInt>(button_id, container);
#endif
}

virtual Json::Value SerializeImpl() const override
Expand All @@ -88,9 +122,13 @@ namespace ProtocolCraft
}

private:
#if PROTOCOL_VERSION < 766 /* < 1.20.5 */
char container_id = 0;
char button_id = 0;

#else
int container_id = 0;
int button_id = 0;
#endif
};
} //ProtocolCraft
#endif

0 comments on commit 30f32b9

Please sign in to comment.