Botcraft 1.21.4
Loading...
Searching...
No Matches
VibrationParticleOptions.hpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
2#pragma once
3
5
6#if PROTOCOL_VERSION < 759 /* < 1.19 */
8#else
10#endif
11
12namespace ProtocolCraft
13{
15 {
16 public:
18 virtual ~VibrationParticleOptions() override {}
19
20#if PROTOCOL_VERSION < 759 /* < 1.19 */
21 const VibrationPath& GetVibrationPath() const
22 {
23 return vibration_path;
24 }
25#else
26#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
31#else
32 const Identifier& GetDestinationType() const
33 {
34 return destination_type;
35 }
36#endif
37 const std::shared_ptr<PositionSource>& GetDestination() const
38 {
39 return destination;
40 }
41
43 {
44 return arrival_in_ticks;
45 }
46#endif
47
48#if PROTOCOL_VERSION < 759 /* < 1.19 */
49 auto& SetVibrationPath(const VibrationPath& vibration_path_)
50 {
51 vibration_path = vibration_path_;
52 return *this;
53 }
54#else
55#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
56 auto& SetDestinationType(const PositionSourceType destination_type_)
57 {
58 destination_type = destination_type_;
59 return *this;
60 }
61#else
62 auto& SetDestinationType(const Identifier& destination_type_)
63 {
64 destination_type = destination_type_;
65 return *this;
66 }
67#endif
68 auto& SetDestination(const std::shared_ptr<PositionSource>& destination_)
69 {
70 destination = destination_;
71 return *this;
72 }
73
74 auto& SetArrivalInTicks(const int arrival_in_ticks_)
75 {
76 arrival_in_ticks = arrival_in_ticks_;
77 return *this;
78 }
79#endif
80
81 protected:
82 virtual void ReadImpl(ReadIterator& iter, size_t& length) override
83 {
84#if PROTOCOL_VERSION < 759 /* < 1.19 */
85 vibration_path = ReadData<VibrationPath>(iter, length);
86#else
87#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
88 destination_type = ReadData<PositionSourceType, VarInt>(iter, length);
89#else
90 destination_type = ReadData<Identifier>(iter, length);
91#endif
93 destination->Read(iter, length);
94 arrival_in_ticks = ReadData<VarInt>(iter, length);
95#endif
96 }
97
98 virtual void WriteImpl(WriteContainer& container) const override
99 {
100#if PROTOCOL_VERSION < 759 /* < 1.19 */
101 WriteData<VibrationPath>(vibration_path, container);
102#else
103#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
104 WriteData<PositionSourceType, VarInt>(destination_type, container);
105#else
106 WriteData<Identifier>(destination_type, container);
107#endif
108 destination->Write(container);
109 WriteData<VarInt>(arrival_in_ticks, container);
110#endif
111 }
112
113 virtual Json::Value SerializeImpl() const override
114 {
115 Json::Value output;
116
117#if PROTOCOL_VERSION < 759 /* < 1.19 */
118 output["vibration_path"] = vibration_path;
119#else
120 output["destination_type"] = destination_type;
121 output["destination"] = destination->Serialize();
122 output["arrival_in_ticks"] = arrival_in_ticks;
123#endif
124 return output;
125 }
126
127 private:
128#if PROTOCOL_VERSION < 759 /* < 1.19 */
129 VibrationPath vibration_path;
130#else
131#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
133#else
135#endif
136 std::shared_ptr<PositionSource> destination;
138#endif
139 };
140}
141#endif
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45
static std::shared_ptr< PositionSource > CreatePositionSource(const PositionSourceType position_source_type)
std::shared_ptr< PositionSource > destination
auto & SetDestination(const std::shared_ptr< PositionSource > &destination_)
const std::shared_ptr< PositionSource > & GetDestination() const
virtual Json::Value SerializeImpl() const override
auto & SetDestinationType(const PositionSourceType destination_type_)
virtual void WriteImpl(WriteContainer &container) const override
auto & SetArrivalInTicks(const int arrival_in_ticks_)
virtual void ReadImpl(ReadIterator &iter, size_t &length) override
std::vector< unsigned char > WriteContainer
std::vector< unsigned char >::const_iterator ReadIterator