Botcraft 1.21.10
Loading...
Searching...
No Matches
ClientboundExplodePacket.hpp
Go to the documentation of this file.
1#pragma once
2
7#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
10#endif
11#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
13#endif
14#if PROTOCOL_VERSION > 772 /* > 1.21.8 */
16#endif
17
18namespace ProtocolCraft
19{
20 class ClientboundExplodePacket : public BasePacket<ClientboundExplodePacket>
21 {
22 public:
23 static constexpr std::string_view packet_name = "Explode";
24
25#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
26 private:
27 std::vector<NetworkPosition> ReadToBlow(ReadIterator& iter, size_t& length) const
28 {
29 std::vector<NetworkPosition> to_blow(
30#if PROTOCOL_VERSION < 755 /* < 1.17 */
31 ReadData<int>(iter, length)
32#else
33 ReadData<VarInt>(iter, length)
34#endif
35 );
36
37 for (size_t i = 0; i < to_blow.size(); ++i)
38 {
39 to_blow[i].SetX(ReadData<int, char>(iter, length));
40 to_blow[i].SetY(ReadData<int, char>(iter, length));
41 to_blow[i].SetZ(ReadData<int, char>(iter, length));
42 }
43
44 return to_blow;
45 }
46
47 void WriteToBlow(const std::vector<NetworkPosition>& to_blow, WriteContainer& container) const
48 {
49#if PROTOCOL_VERSION < 755 /* < 1.17 */
50 WriteData<int>(static_cast<int>(to_blow.size()), container);
51#else
52 WriteData<VarInt>(static_cast<int>(to_blow.size()), container);
53#endif
54
55 for (size_t i = 0; i < to_blow.size(); ++i)
56 {
57 WriteData<int, char>(to_blow[i].GetX(), container);
58 WriteData<int, char>(to_blow[i].GetY(), container);
59 WriteData<int, char>(to_blow[i].GetZ(), container);
60 }
61 }
62#endif
63
64#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
65 SERIALIZED_FIELD(X, float);
66 SERIALIZED_FIELD(Y, float);
67 SERIALIZED_FIELD(Z, float);
68#elif PROTOCOL_VERSION < 768 /* < 1.21.2 */
69 SERIALIZED_FIELD(X, double);
70 SERIALIZED_FIELD(Y, double);
71 SERIALIZED_FIELD(Z, double);
72#else
73 SERIALIZED_FIELD(Center, std::array<double, 3>);
74#endif
75#if PROTOCOL_VERSION > 772 /* > 1.21.8 */
76 SERIALIZED_FIELD(Radius, float);
77 SERIALIZED_FIELD(BlockCount, int);
78#endif
79#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
80 SERIALIZED_FIELD(Power, float);
81 SERIALIZED_FIELD(ToBlow, Internal::CustomType<std::vector<NetworkPosition>, &THIS::ReadToBlow, &THIS::WriteToBlow>);
82#endif
83#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
84 SERIALIZED_FIELD(KnockbackX, float);
85 SERIALIZED_FIELD(KnockbackY, float);
86 SERIALIZED_FIELD(KnockbackZ, float);
87#else
88 SERIALIZED_FIELD(PlayerKnockback, std::optional<std::array<double, 3>>);
89#endif
90#if PROTOCOL_VERSION > 764 /* > 1.20.2 */ && PROTOCOL_VERSION < 768 /* < 1.21.2 */
91 SERIALIZED_FIELD(BlockInteraction, VarInt);
92 SERIALIZED_FIELD(SmallExplosionParticles, Particle);
93 SERIALIZED_FIELD(LargeExplosionParticles, Particle);
94#endif
95#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
96 SERIALIZED_FIELD(ExplosionParticle, Particle);
97#endif
98#if PROTOCOL_VERSION > 764 /* > 1.20.2 */ && PROTOCOL_VERSION < 766 /* < 1.20.5 */
99 SERIALIZED_FIELD(ExplosionSound, SoundEvent);
100#elif PROTOCOL_VERSION > 764 /* > 1.20.2 */
102#endif
103#if PROTOCOL_VERSION > 772 /* > 1.21.8 */
104 SERIALIZED_FIELD(BlockParticles, std::vector<std::pair<VarInt, ExplosionParticleInfo>>);
105#endif
106
108 };
109} //ProtocolCraft
#define SERIALIZED_FIELD(Name,...)
SERIALIZED_FIELD(PlayerKnockback, std::optional< std::array< double, 3 > >)
SERIALIZED_FIELD(BlockParticles, std::vector< std::pair< VarInt, ExplosionParticleInfo > >)
SERIALIZED_FIELD(ExplosionSound, Holder< SoundEvent >)
SERIALIZED_FIELD(Center, std::array< double, 3 >)
SERIALIZED_FIELD(ExplosionParticle, Particle)
static constexpr std::string_view packet_name
std::vector< unsigned char > WriteContainer
std::vector< unsigned char >::const_iterator ReadIterator