Botcraft 26.2
Loading...
Searching...
No Matches
DataComponents.hpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
2#pragma once
4
5// Use map instead of unordered to avoid another include everywhere
6#include <map>
7#include <memory>
8#include <string_view>
9
10namespace ProtocolCraft
11{
12 namespace Components
13 {
15 {
16 None = -1,
20 Damage,
22#if PROTOCOL_VERSION > 773 /* > 1.21.10 */
24#endif
26#if PROTOCOL_VERSION > 773 /* > 1.21.10 */
29#endif
31#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
33#endif
34 Lore,
35 Rarity,
41#if PROTOCOL_VERSION < 770 /* < 1.21.5 */
42 HideAdditionalTooltip,
43 HideTooltip,
44#else
46#endif
51 Food,
52#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
53 FireResistant,
54#endif
55#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
60#endif
61 Tool,
62#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
63 Weapon,
64#endif
65#if PROTOCOL_VERSION > 773 /* > 1.21.10 */
67#endif
68#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
72 Glider,
75#endif
76#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
78#endif
79#if PROTOCOL_VERSION > 773 /* > 1.21.10 */
83#endif
84#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
86#endif
88#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
89 Dye,
90#endif
93 MapId,
99#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
101#endif
105 Trim,
111#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
113#endif
115#if PROTOCOL_VERSION > 766 /* > 1.20.6 */
117#endif
118#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
120#endif
121 Recipes,
124 Fireworks,
125 Profile,
128 BaseColor,
130 Container,
132 Bees,
133#if PROTOCOL_VERSION > 775 /* > 26.1.2 */
135#endif
136 Lock,
138#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
153#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
155#endif
157#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
159#endif
161#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
163#endif
164#if PROTOCOL_VERSION > 773 /* > 1.21.10 */
166#endif
173#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
175#endif
179#endif
181 };
182
183 std::string_view DataComponentTypesToString(const DataComponentTypes type);
184
185 class DataComponentType;
186
188 {
189 public:
190 virtual ~DataComponentPredicate() override;
191
192 const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& GetMap() const;
193 DataComponentPredicate& SetMap(const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& map_);
194
195 protected:
196 virtual void ReadImpl(ReadIterator& iter, size_t& length) override;
197 virtual void WriteImpl(WriteContainer& container) const override;
198 virtual Json::Value SerializeImpl() const override;
199
200 private:
201 std::map<DataComponentTypes, std::shared_ptr<DataComponentType>> map;
202
203 };
204
205#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
207#endif
208
210 {
211 public:
213#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
215#endif
216 virtual ~DataComponentPatch() override;
217
218 const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& GetMap() const;
219 DataComponentPatch& SetMap(const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& map_);
220
221 protected:
222 virtual void ReadImpl(ReadIterator& iter, size_t& length) override;
223 virtual void WriteImpl(WriteContainer& container) const override;
224 virtual Json::Value SerializeImpl() const override;
225
226 private:
227 std::map<DataComponentTypes, std::shared_ptr<DataComponentType>> map;
228
229 };
230
231#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
233 {
234 public:
237
238 SERIALIZED_FIELD(AddedComponents, Internal::DiffType<std::map<DataComponentTypes, int>, std::map<VarInt, int>>);
239 SERIALIZED_FIELD(RemovedComponents, Internal::DiffType<std::vector<DataComponentTypes>, std::vector<VarInt>>);
240
242 };
243
245 {
246 public:
249
250 const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& GetMap() const;
251 LengthPrefixedDataComponentPatch& SetMap(const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& map_);
252
253 protected:
254 virtual void ReadImpl(ReadIterator& iter, size_t& length) override;
255 virtual void WriteImpl(WriteContainer& container) const override;
256 virtual Json::Value SerializeImpl() const override;
257
258 private:
259 std::map<DataComponentTypes, std::shared_ptr<DataComponentType>> map;
260 };
261#endif
262 }
263}
264#endif
virtual Json::Value SerializeImpl() const override
std::map< DataComponentTypes, std::shared_ptr< DataComponentType > > map
const std::map< DataComponentTypes, std::shared_ptr< DataComponentType > > & GetMap() const
virtual void ReadImpl(ReadIterator &iter, size_t &length) override
DataComponentPatch & SetMap(const std::map< DataComponentTypes, std::shared_ptr< DataComponentType > > &map_)
virtual void WriteImpl(WriteContainer &container) const override
virtual void WriteImpl(WriteContainer &container) const override
std::map< DataComponentTypes, std::shared_ptr< DataComponentType > > map
virtual Json::Value SerializeImpl() const override
virtual void ReadImpl(ReadIterator &iter, size_t &length) override
const std::map< DataComponentTypes, std::shared_ptr< DataComponentType > > & GetMap() const
DataComponentPredicate & SetMap(const std::map< DataComponentTypes, std::shared_ptr< DataComponentType > > &map_)
SERIALIZED_FIELD(AddedComponents, Internal::DiffType< std::map< DataComponentTypes, int >, std::map< VarInt, int > >)
SERIALIZED_FIELD(RemovedComponents, Internal::DiffType< std::vector< DataComponentTypes >, std::vector< VarInt > >)
virtual void ReadImpl(ReadIterator &iter, size_t &length) override
std::map< DataComponentTypes, std::shared_ptr< DataComponentType > > map
const std::map< DataComponentTypes, std::shared_ptr< DataComponentType > > & GetMap() const
virtual void WriteImpl(WriteContainer &container) const override
LengthPrefixedDataComponentPatch & SetMap(const std::map< DataComponentTypes, std::shared_ptr< DataComponentType > > &map_)
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45
std::string_view DataComponentTypesToString(const DataComponentTypes type)
std::vector< unsigned char > WriteContainer
std::vector< unsigned char >::const_iterator ReadIterator
Just a simple type wrapper that will store with T1 and serialize as T2 (can be used for Enum/VarInt f...
Definition Templates.hpp:72