Botcraft 1.21.4
Loading...
Searching...
No Matches
EnderManEntity.cpp
Go to the documentation of this file.
2
3#include <mutex>
4
5namespace Botcraft
6{
7 const std::array<std::string, EnderManEntity::metadata_count> EnderManEntity::metadata_names{ {
8 "data_carry_state",
9 "data_creepy",
10#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
11 "data_stared_at",
12#endif
13 } };
14
16 {
17 // Initialize all metadata with default values
19 SetDataCreepy(false);
20#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
21 SetDataStaredAt(false);
22#endif
23
24 // Initialize all attributes with default values
29#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
31#endif
32 }
33
38
39
40 std::string EnderManEntity::GetName() const
41 {
42 return "enderman";
43 }
44
49
50
52 {
53 return "enderman";
54 }
55
60
61
63 {
65
66 output["metadata"]["data_carry_state"] = GetDataCarryState();
67 output["metadata"]["data_creepy"] = GetDataCreepy();
68#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
69 output["metadata"]["data_stared_at"] = GetDataStaredAt();
70#endif
71
72 return output;
73 }
74
75
76 void EnderManEntity::SetMetadataValue(const int index, const std::any& value)
77 {
78 if (index < hierarchy_metadata_count)
79 {
81 }
83 {
84 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
86 }
87 }
88
90 {
91 std::shared_lock<std::shared_mutex> lock(entity_mutex);
92 return std::any_cast<int>(metadata.at("data_carry_state"));
93 }
94
96 {
97 std::shared_lock<std::shared_mutex> lock(entity_mutex);
98 return std::any_cast<bool>(metadata.at("data_creepy"));
99 }
100
101#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
103 {
104 std::shared_lock<std::shared_mutex> lock(entity_mutex);
105 return std::any_cast<bool>(metadata.at("data_stared_at"));
106 }
107#endif
108
109
110 void EnderManEntity::SetDataCarryState(const int data_carry_state)
111 {
112 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
113 metadata["data_carry_state"] = data_carry_state;
114 }
115
116 void EnderManEntity::SetDataCreepy(const bool data_creepy)
117 {
118 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
119 metadata["data_creepy"] = data_creepy;
120 }
121
122#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
123 void EnderManEntity::SetDataStaredAt(const bool data_stared_at)
124 {
125 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
126 metadata["data_stared_at"] = data_stared_at;
127 }
128#endif
129
130
132 {
133 return 0.6;
134 }
135
137 {
138 return 2.9;
139 }
140
141}
void SetDataCarryState(const int data_carry_state)
virtual std::string GetName() const override
virtual double GetWidthImpl() const override
virtual void SetMetadataValue(const int index, const std::any &value) override
static const std::array< std::string, metadata_count > metadata_names
void SetDataStaredAt(const bool data_stared_at)
static constexpr int hierarchy_metadata_count
virtual double GetHeightImpl() const override
static EntityType GetClassType()
virtual ProtocolCraft::Json::Value Serialize() const override
static std::string GetClassName()
void SetDataCreepy(const bool data_creepy)
static constexpr int metadata_count
virtual EntityType GetType() const override
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
virtual ProtocolCraft::Json::Value Serialize() const override
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45