Botcraft 1.21.5
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,
24#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
26#endif
27 Lore,
28 Rarity,
34#if PROTOCOL_VERSION < 770 /* < 1.21.5 */
35 HideAdditionalTooltip,
36 HideTooltip,
37#else
39#endif
44 Food,
45#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
46 FireResistant,
47#endif
48#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
53#endif
54 Tool,
55#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
56 Weapon,
57#endif
58#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
62 Glider,
65#endif
66#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
68#endif
72 MapId,
78#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
80#endif
84 Trim,
90#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
92#endif
94#if PROTOCOL_VERSION > 766 /* > 1.20.6 */
96#endif
97#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
99#endif
100 Recipes,
103 Fireworks,
104 Profile,
107 BaseColor,
109 Container,
111 Bees,
112 Lock,
114#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
140#endif
142 };
143
144 std::string_view DataComponentTypesToString(const DataComponentTypes type);
145
146 class DataComponentType;
147
149 {
150 public:
151 virtual ~DataComponentPredicate() override;
152
153 const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& GetMap() const;
154 DataComponentPredicate& SetMap(const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& map_);
155
156 protected:
157 virtual void ReadImpl(ReadIterator& iter, size_t& length) override;
158 virtual void WriteImpl(WriteContainer& container) const override;
159 virtual Json::Value SerializeImpl() const override;
160
161 private:
162 std::map<DataComponentTypes, std::shared_ptr<DataComponentType>> map;
163
164 };
165
167 {
168 public:
169 virtual ~DataComponentPatch() override;
170
171 const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& GetMap() const;
172 DataComponentPatch& 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
184#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
186 {
187 public:
190
191 SERIALIZED_FIELD(AddedComponents, Internal::DiffType<std::map<DataComponentTypes, int>, std::map<VarInt, int>>);
192 SERIALIZED_FIELD(RemovedComponents, Internal::DiffType<std::vector<DataComponentTypes>, std::vector<VarInt>>);
193
195 };
196#endif
197 }
198}
199#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