Botcraft 26.3
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 */
82#endif
83#if PROTOCOL_VERSION > 773 /* > 1.21.10 */ && PROTOCOL_VERSION < 777 /* < 26.3 */
85#endif
86#if PROTOCOL_VERSION > 776 /* > 26.2 */
89#endif
90#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
92#endif
93#if PROTOCOL_VERSION > 776 /* > 26.2 */
96#endif
98#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
99 Dye,
100#endif
101 DyedColor,
102#if PROTOCOL_VERSION < 777 /* < 26.3 */
103 MapColor,
104#endif
105 MapId,
111#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
113#endif
117 Trim,
123#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
125#endif
127#if PROTOCOL_VERSION > 766 /* > 1.20.6 */
129#endif
130#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
132#endif
133 Recipes,
136 Fireworks,
137 Profile,
140 BaseColor,
142 Container,
144 Bees,
145#if PROTOCOL_VERSION > 775 /* > 26.1.2 */
147#endif
148 Lock,
150#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
152#if PROTOCOL_VERSION > 776 /* > 26.2 */
157#endif
171#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
173#endif
175#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
177#endif
179#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
181#endif
182#if PROTOCOL_VERSION > 773 /* > 1.21.10 */
184#endif
191#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
193#endif
197#endif
198#if PROTOCOL_VERSION > 776 /* > 26.2 */
202 Waxed,
204#endif
206 };
207
208 std::string_view DataComponentTypesToString(const DataComponentTypes type);
209
210 class DataComponentType;
211
213 {
214 public:
215 virtual ~DataComponentPredicate() override;
216
217 const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& GetMap() const;
218 DataComponentPredicate& SetMap(const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& map_);
219
220 protected:
221 virtual void ReadImpl(ReadIterator& iter, size_t& length) override;
222 virtual void WriteImpl(WriteContainer& container) const override;
223 virtual Json::Value SerializeImpl() const override;
224
225 private:
226 std::map<DataComponentTypes, std::shared_ptr<DataComponentType>> map;
227
228 };
229
230#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
232#endif
233
235 {
236 public:
238#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
240#endif
241 virtual ~DataComponentPatch() override;
242
243 const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& GetMap() const;
244 DataComponentPatch& SetMap(const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& map_);
245
246 protected:
247 virtual void ReadImpl(ReadIterator& iter, size_t& length) override;
248 virtual void WriteImpl(WriteContainer& container) const override;
249 virtual Json::Value SerializeImpl() const override;
250
251 private:
252 std::map<DataComponentTypes, std::shared_ptr<DataComponentType>> map;
253
254 };
255
256#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
258 {
259 public:
262
263 SERIALIZED_FIELD(AddedComponents, Internal::DiffType<std::map<DataComponentTypes, int>, std::map<VarInt, int>>);
264 SERIALIZED_FIELD(RemovedComponents, Internal::DiffType<std::vector<DataComponentTypes>, std::vector<VarInt>>);
265
267 };
268
270 {
271 public:
274
275 const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& GetMap() const;
276 LengthPrefixedDataComponentPatch& SetMap(const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& map_);
277
278 protected:
279 virtual void ReadImpl(ReadIterator& iter, size_t& length) override;
280 virtual void WriteImpl(WriteContainer& container) const override;
281 virtual Json::Value SerializeImpl() const override;
282
283 private:
284 std::map<DataComponentTypes, std::shared_ptr<DataComponentType>> map;
285 };
286#endif
287 }
288}
289#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