Botcraft 1.21.4
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
15namespace ProtocolCraft
16{
17 class ClientboundExplodePacket : public BaseMessage<ClientboundExplodePacket>
18 {
19 public:
20 static constexpr std::string_view packet_name = "Explode";
21
22 private:
23 std::vector<NetworkPosition> ReadToBlow(ReadIterator& iter, size_t& length) const
24 {
25 std::vector<NetworkPosition> to_blow(
26#if PROTOCOL_VERSION < 755 /* < 1.17 */
27 ReadData<int>(iter, length)
28#else
29 ReadData<VarInt>(iter, length)
30#endif
31 );
32
33 for (size_t i = 0; i < to_blow.size(); ++i)
34 {
35 to_blow[i].SetX(ReadData<int, char>(iter, length));
36 to_blow[i].SetY(ReadData<int, char>(iter, length));
37 to_blow[i].SetZ(ReadData<int, char>(iter, length));
38 }
39
40 return to_blow;
41 }
42
43 void WriteToBlow(const std::vector<NetworkPosition>& to_blow, WriteContainer& container) const
44 {
45#if PROTOCOL_VERSION < 755 /* < 1.17 */
46 WriteData<int>(static_cast<int>(to_blow.size()), container);
47#else
48 WriteData<VarInt>(static_cast<int>(to_blow.size()), container);
49#endif
50
51 for (size_t i = 0; i < to_blow.size(); ++i)
52 {
53 WriteData<int, char>(to_blow[i].GetX(), container);
54 WriteData<int, char>(to_blow[i].GetY(), container);
55 WriteData<int, char>(to_blow[i].GetZ(), container);
56 }
57 }
58
59#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
60 SERIALIZED_FIELD(X, float);
61 SERIALIZED_FIELD(Y, float);
62 SERIALIZED_FIELD(Z, float);
63#elif PROTOCOL_VERSION < 768 /* < 1.21.2 */
64 SERIALIZED_FIELD(X, double);
65 SERIALIZED_FIELD(Y, double);
66 SERIALIZED_FIELD(Z, double);
67#else
68 SERIALIZED_FIELD(Center, std::array<double, 3>);
69#endif
70#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
71 SERIALIZED_FIELD(Power, float);
72 SERIALIZED_FIELD(ToBlow, Internal::CustomType<std::vector<NetworkPosition>, &THIS::ReadToBlow, &THIS::WriteToBlow>);
73#endif
74#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
75 SERIALIZED_FIELD(KnockbackX, float);
76 SERIALIZED_FIELD(KnockbackY, float);
77 SERIALIZED_FIELD(KnockbackZ, float);
78#else
79 SERIALIZED_FIELD(PlayerKnockback, std::optional<std::array<double, 3>>);
80#endif
81#if PROTOCOL_VERSION > 764 /* > 1.20.2 */ && PROTOCOL_VERSION < 768 /* < 1.21.2 */
82 SERIALIZED_FIELD(BlockInteraction, VarInt);
83 SERIALIZED_FIELD(SmallExplosionParticles, Particle);
84 SERIALIZED_FIELD(LargeExplosionParticles, Particle);
85#endif
86#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
87 SERIALIZED_FIELD(ExplosionParticle, Particle);
88#endif
89#if PROTOCOL_VERSION > 764 /* > 1.20.2 */ && PROTOCOL_VERSION < 766 /* < 1.20.5 */
90 SERIALIZED_FIELD(ExplosionSound, SoundEvent);
91#elif PROTOCOL_VERSION > 764 /* > 1.20.2 */
93#endif
94
96 };
97} //ProtocolCraft
#define SERIALIZED_FIELD(Name,...)
std::vector< NetworkPosition > ReadToBlow(ReadIterator &iter, size_t &length) const
SERIALIZED_FIELD(PlayerKnockback, std::optional< std::array< double, 3 > >)
void WriteToBlow(const std::vector< NetworkPosition > &to_blow, WriteContainer &container) const
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