Botcraft 1.21.4
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,
40 Food,
41#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
42 FireResistant,
43#endif
44#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
49#endif
50 Tool,
51#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
55 Glider,
58#endif
62 MapId,
71 Trim,
78#if PROTOCOL_VERSION > 766 /* > 1.20.6 */
80#endif
81 Recipes,
85 Profile,
92 Bees,
93 Lock,
96 };
97
98 std::string_view DataComponentTypesToString(const DataComponentTypes type);
99
100 class DataComponentType;
101
103 {
104 public:
105 virtual ~DataComponentPredicate() override;
106
107 const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& GetMap() const;
108 DataComponentPredicate& SetMap(const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& map_);
109
110 protected:
111 virtual void ReadImpl(ReadIterator& iter, size_t& length) override;
112 virtual void WriteImpl(WriteContainer& container) const override;
113 virtual Json::Value SerializeImpl() const override;
114
115 private:
116 std::map<DataComponentTypes, std::shared_ptr<DataComponentType>> map;
117
118 };
119
121 {
122 public:
123 virtual ~DataComponentPatch() override;
124
125 const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& GetMap() const;
126 DataComponentPatch& SetMap(const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& map_);
127
128 protected:
129 virtual void ReadImpl(ReadIterator& iter, size_t& length) override;
130 virtual void WriteImpl(WriteContainer& container) const override;
131 virtual Json::Value SerializeImpl() const override;
132
133 private:
134 std::map<DataComponentTypes, std::shared_ptr<DataComponentType>> map;
135
136 };
137 }
138}
139#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_)
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