Botcraft 1.21.11
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
87 MapId,
93#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
95#endif
99 Trim,
105#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
107#endif
109#if PROTOCOL_VERSION > 766 /* > 1.20.6 */
111#endif
112#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
114#endif
115 Recipes,
118 Fireworks,
119 Profile,
122 BaseColor,
124 Container,
126 Bees,
127 Lock,
129#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
146#if PROTOCOL_VERSION > 773 /* > 1.21.10 */
148#endif
158#endif
160 };
161
162 std::string_view DataComponentTypesToString(const DataComponentTypes type);
163
164 class DataComponentType;
165
167 {
168 public:
169 virtual ~DataComponentPredicate() override;
170
171 const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& GetMap() const;
172 DataComponentPredicate& SetMap(const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& map_);
173
174 protected:
175 virtual void ReadImpl(ReadIterator& iter, size_t& length) override;
176 virtual void WriteImpl(WriteContainer& container) const override;
177 virtual Json::Value SerializeImpl() const override;
178
179 private:
180 std::map<DataComponentTypes, std::shared_ptr<DataComponentType>> map;
181
182 };
183
185 {
186 public:
187 virtual ~DataComponentPatch() override;
188
189 const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& GetMap() const;
190 DataComponentPatch& 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
202#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
204 {
205 public:
208
209 SERIALIZED_FIELD(AddedComponents, Internal::DiffType<std::map<DataComponentTypes, int>, std::map<VarInt, int>>);
210 SERIALIZED_FIELD(RemovedComponents, Internal::DiffType<std::vector<DataComponentTypes>, std::vector<VarInt>>);
211
213 };
214#endif
215 }
216}
217#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