Botcraft 1.21.7
Loading...
Searching...
No Matches
HappyGhastEntity.cpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 770 /* > 1.21.5 */
3
4#include <mutex>
5
6namespace Botcraft
7{
8 const std::array<std::string, HappyGhastEntity::metadata_count> HappyGhastEntity::metadata_names{ {
9 "is_leash_holder",
10 "stays_still",
11 } };
12
27
32
33
34 std::string HappyGhastEntity::GetName() const
35 {
36 return "happy_ghast";
37 }
38
43
44
46 {
47 return "happy_ghast";
48 }
49
54
55
57 {
59
60 output["metadata"]["is_leash_holder"] = GetIsLeashHolder();
61 output["metadata"]["stays_still"] = GetStaysStill();
62
63 output["attributes"]["flying_speed"] = GetAttributeFlyingSpeedValue();
64
65 return output;
66 }
67
68
69 void HappyGhastEntity::SetMetadataValue(const int index, const std::any& value)
70 {
71 if (index < hierarchy_metadata_count)
72 {
74 }
76 {
77 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
79 }
80 }
81
83 {
84 std::shared_lock<std::shared_mutex> lock(entity_mutex);
85 return std::any_cast<int>(metadata.at("is_leash_holder"));
86 }
87
89 {
90 std::shared_lock<std::shared_mutex> lock(entity_mutex);
91 return std::any_cast<int>(metadata.at("stays_still"));
92 }
93
94
95 void HappyGhastEntity::SetIsLeashHolder(const int is_leash_holder)
96 {
97 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
98 metadata["is_leash_holder"] = is_leash_holder;
99 }
100
101 void HappyGhastEntity::SetStaysStill(const int stays_still)
102 {
103 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
104 metadata["stays_still"] = stays_still;
105 }
106
107
109 {
110 std::shared_lock<std::shared_mutex> lock(entity_mutex);
112 }
113
114
116 {
117 return 4.0;
118 }
119
121 {
122 return 4.0;
123 }
124
125}
126#endif
virtual void SetMetadataValue(const int index, const std::any &value) override
virtual ProtocolCraft::Json::Value Serialize() const override
std::shared_mutex entity_mutex
Definition Entity.hpp:261
std::map< std::string, std::any > metadata
Definition Entity.hpp:276
static constexpr int hierarchy_metadata_count
double GetAttributeFlyingSpeedValue() const
static EntityType GetClassType()
virtual std::string GetName() const override
virtual ProtocolCraft::Json::Value Serialize() const override
static constexpr int metadata_count
static const std::array< std::string, metadata_count > metadata_names
void SetIsLeashHolder(const int is_leahs_holder)
virtual double GetWidthImpl() const override
virtual EntityType GetType() const override
virtual double GetHeightImpl() const override
static std::string GetClassName()
void SetStaysStill(const int stays_still)
virtual void SetMetadataValue(const int index, const std::any &value) override
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