Botcraft 1.21.4
Loading...
Searching...
No Matches
ClientboundLightUpdatePacket.hpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
2#pragma once
3
6#if PROTOCOL_VERSION > 756 /* > 1.17.1 */
8#endif
9
10namespace ProtocolCraft
11{
12 class ClientboundLightUpdatePacket : public BaseMessage<ClientboundLightUpdatePacket>
13 {
14 public:
15 static constexpr std::string_view packet_name = "Light Update";
16
17#if PROTOCOL_VERSION < 755 /* < 1.17 */
18 private:
19 std::vector<std::vector<char>> ReadSkyUpdates(ReadIterator& iter, size_t& length) const
20 {
21 std::vector<std::vector<char>> sky_updates;
22 sky_updates.reserve(18);
23 for (int i = 0; i < 18; ++i)
24 {
25 if ((GetSkyYMask() >> i) & 1)
26 {
27 sky_updates.push_back(ReadData<std::vector<char>>(iter, length)); // Should always contain 2048 chars
28 }
29 }
30 return sky_updates;
31 }
32
33 void WriteSkyUpdates(const std::vector<std::vector<char>>& sky_updates, WriteContainer& container) const
34 {
35 for (const auto& v : sky_updates)
36 {
37 WriteData<std::vector<char>>(v, container);
38 }
39 }
40
41 std::vector<std::vector<char>> ReadBlockUpdates(ReadIterator& iter, size_t& length) const
42 {
43 std::vector<std::vector<char>> block_updates;
44 block_updates.reserve(18);
45 for (int i = 0; i < 18; ++i)
46 {
47 if ((GetBlockYMask() >> i) & 1)
48 {
49 block_updates.push_back(ReadData<std::vector<char>>(iter, length)); // Should always contain 2048 chars
50 }
51 }
52 return block_updates;
53 }
54
55 void WriteBlockUpdates(const std::vector<std::vector<char>>& block_updates, WriteContainer& container) const
56 {
57 for (const auto& v : block_updates)
58 {
59 WriteData<std::vector<char>>(v, container);
60 }
61 }
62#endif
63
66#if PROTOCOL_VERSION > 722 /* > 1.15.2 */ && PROTOCOL_VERSION < 757 /* < 1.18 */
67 SERIALIZED_FIELD(TrustEdges, bool);
68#endif
69#if PROTOCOL_VERSION < 755 /* < 1.17 */
70 SERIALIZED_FIELD(SkyYMask, VarInt);
71 SERIALIZED_FIELD(BlockYMask, VarInt);
72 SERIALIZED_FIELD(EmptySkyYMask, VarInt);
73 SERIALIZED_FIELD(EmptyBlockYMask, VarInt);
74 SERIALIZED_FIELD(SkyUpdates, Internal::CustomType<std::vector<std::vector<char>>, &THIS::ReadSkyUpdates, &THIS::WriteSkyUpdates>);
75 SERIALIZED_FIELD(BlockUpdates, Internal::CustomType<std::vector<std::vector<char>>, &THIS::ReadBlockUpdates, &THIS::WriteBlockUpdates>);
76#elif PROTOCOL_VERSION < 757 /* < 1.18 */
77 SERIALIZED_FIELD(SkyYMask, std::vector<unsigned long long int>);
78 SERIALIZED_FIELD(BlockYMask, std::vector<unsigned long long int>);
79 SERIALIZED_FIELD(EmptySkyYMask, std::vector<unsigned long long int>);
80 SERIALIZED_FIELD(EmptyBlockYMask, std::vector<unsigned long long int>);
81 SERIALIZED_FIELD(SkyUpdates, std::vector<std::vector<char>>);
82 SERIALIZED_FIELD(BlockUpdates, std::vector<std::vector<char>>);
83#endif
84#if PROTOCOL_VERSION > 756 /* > 1.17.1 */
86#endif
87
89 };
90} //ProtocolCraft
91
92#endif
#define SERIALIZED_FIELD(Name,...)
SERIALIZED_FIELD(LightData, ClientboundLightUpdatePacketData)
StorageType ReadData(ReadIterator &iter, size_t &length)
std::vector< unsigned char > WriteContainer
std::vector< unsigned char >::const_iterator ReadIterator