Botcraft 1.21.4
Loading...
Searching...
No Matches
ClientboundAwardStatsPacket.hpp
Go to the documentation of this file.
1#pragma once
2
4#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
6#endif
7
8#include <map>
9
10namespace ProtocolCraft
11{
12 class ClientboundAwardStatsPacket : public BaseMessage<ClientboundAwardStatsPacket>
13 {
14 public:
15 static constexpr std::string_view packet_name = "Award Stats";
16
17#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
18 private:
19 std::optional<Json::Value> SerializeStats(const std::map<std::pair<int, int>, int>& stats) const
20 {
21 Json::Array output;
22 for (const auto& p : stats)
23 {
24 output.push_back({
25 {"category_id", p.first.first},
26 {"stats_id", p.first.second},
27 {"value", p.second}
28 });
29 }
30 return output;
31 }
32#endif
33
34#if PROTOCOL_VERSION < 393 /* < 1.13 */
35 SERIALIZED_FIELD(Stats, std::map<std::string, VarInt>);
36#else
37 SERIALIZED_FIELD(Stats, Internal::CustomType<std::map<std::pair<VarInt, VarInt>, VarInt>, nullptr, nullptr, &THIS::SerializeStats>);
38#endif
39
41 };
42} //ProtocolCraft
#define SERIALIZED_FIELD(Name,...)
SERIALIZED_FIELD(Stats, Internal::CustomType< std::map< std::pair< VarInt, VarInt >, VarInt >, nullptr, nullptr, &THIS::SerializeStats >)
std::optional< Json::Value > SerializeStats(const std::map< std::pair< int, int >, int > &stats) const
Real class declaration, just a derived class of std::vector<Value>
Definition Json.hpp:180