Botcraft 26.1.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 Lock,
135#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
150#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
152#endif
154#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
156#endif
158#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
160#endif
161#if PROTOCOL_VERSION > 773 /* > 1.21.10 */
163#endif
170#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
172#endif
176#endif
178 };
179
180 std::string_view DataComponentTypesToString(const DataComponentTypes type);
181
182 class DataComponentType;
183
185 {
186 public:
187 virtual ~DataComponentPredicate() override;
188
189 const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& GetMap() const;
190 DataComponentPredicate& SetMap(const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& map_);
191
192 protected:
193 virtual void ReadImpl(ReadIterator& iter, size_t& length) override;
194 virtual void WriteImpl(WriteContainer& container) const override;
195 virtual Json::Value SerializeImpl() const override;
196
197 private:
198 std::map<DataComponentTypes, std::shared_ptr<DataComponentType>> map;
199
200 };
201
203 {
204 public:
205 virtual ~DataComponentPatch() override;
206
207 const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& GetMap() const;
208 DataComponentPatch& SetMap(const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& map_);
209
210 protected:
211 virtual void ReadImpl(ReadIterator& iter, size_t& length) override;
212 virtual void WriteImpl(WriteContainer& container) const override;
213 virtual Json::Value SerializeImpl() const override;
214
215 private:
216 std::map<DataComponentTypes, std::shared_ptr<DataComponentType>> map;
217
218 };
219
220#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
222 {
223 public:
226
227 SERIALIZED_FIELD(AddedComponents, Internal::DiffType<std::map<DataComponentTypes, int>, std::map<VarInt, int>>);
228 SERIALIZED_FIELD(RemovedComponents, Internal::DiffType<std::vector<DataComponentTypes>, std::vector<VarInt>>);
229
231 };
232#endif
233 }
234}
235#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 > >)
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