Botcraft 1.21.4
Loading...
Searching...
No Matches
AllayEntity.cpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
3
4#include <mutex>
5
6namespace Botcraft
7{
8#if PROTOCOL_VERSION > 759 /* > 1.19 */
9 const std::array<std::string, AllayEntity::metadata_count> AllayEntity::metadata_names{ {
10 "data_dancing",
11 "data_can_duplicate",
12 } };
13#endif
15 {
16#if PROTOCOL_VERSION > 759 /* > 1.19 */
17 // Initialize all metadata with default values
18 SetDataDancing(true);
20#endif
21
22 // Initialize all attributes with default values
27#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
29#endif
30 }
31
36
37
38 std::string AllayEntity::GetName() const
39 {
40 return "allay";
41 }
42
47
48
50 {
51 return "allay";
52 }
53
58
59
60#if PROTOCOL_VERSION > 759 /* > 1.19 */
62 {
64
65 output["metadata"]["data_dancing"] = GetDataDancing();
66 output["metadata"]["data_can_duplicate"] = GetDataCanDuplicate();
67
68 output["attributes"]["flying_speed"] = GetAttributeFlyingSpeedValue();
69 output["attributes"]["attack_damage"] = GetAttributeAttackDamageValue();
70
71 return output;
72 }
73
74
75 void AllayEntity::SetMetadataValue(const int index, const std::any& value)
76 {
77 if (index < hierarchy_metadata_count)
78 {
80 }
82 {
83 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
85 }
86 }
87
89 {
90 std::shared_lock<std::shared_mutex> lock(entity_mutex);
91 return std::any_cast<bool>(metadata.at("data_dancing"));
92 }
93
95 {
96 std::shared_lock<std::shared_mutex> lock(entity_mutex);
97 return std::any_cast<bool>(metadata.at("data_can_duplicate"));
98 }
99
100
101 void AllayEntity::SetDataDancing(const bool data_dancing)
102 {
103 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
104 metadata["data_dancing"] = data_dancing;
105 }
106
107 void AllayEntity::SetDataCanDuplicate(const bool data_can_duplicate)
108 {
109 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
110 metadata["data_can_duplicate"] = data_can_duplicate;
111 }
112#endif
113
115 {
116 std::shared_lock<std::shared_mutex> lock(entity_mutex);
118 }
119
121 {
122 std::shared_lock<std::shared_mutex> lock(entity_mutex);
124 }
125
127 {
128 return 0.35;
129 }
130
132 {
133 return 0.6;
134 }
135
136}
137#endif
void SetDataCanDuplicate(const bool data_can_duplicate)
bool GetDataDancing() const
double GetAttributeAttackDamageValue() const
virtual void SetMetadataValue(const int index, const std::any &value) override
void SetDataDancing(const bool data_dancing)
static constexpr int metadata_count
double GetAttributeFlyingSpeedValue() const
bool GetDataCanDuplicate() const
static std::string GetClassName()
virtual double GetHeightImpl() const override
virtual ProtocolCraft::Json::Value Serialize() const override
virtual double GetWidthImpl() const override
static constexpr int hierarchy_metadata_count
virtual std::string GetName() const override
virtual EntityType GetType() const override
static const std::array< std::string, metadata_count > metadata_names
static EntityType GetClassType()
virtual ProtocolCraft::Json::Value Serialize() const
Definition Entity.cpp:1095
virtual void SetMetadataValue(const int index, const std::any &value)
Definition Entity.cpp:622
std::shared_mutex entity_mutex
Definition Entity.hpp:253
std::map< std::string, std::any > metadata
Definition Entity.hpp:268
std::map< EntityAttribute::Type, EntityAttribute > attributes
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45