Botcraft 1.21.4
Loading...
Searching...
No Matches
WardenEntity.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 const std::array<std::string, WardenEntity::metadata_count> WardenEntity::metadata_names{ {
9 "client_anger_level",
10 } };
11
27
32
33
34 std::string WardenEntity::GetName() const
35 {
36 return "warden";
37 }
38
43
44
46 {
47 return "warden";
48 }
49
54
55
57 {
59
60 output["client_anger_level"] = GetClientAngerLevel();
61
62 return output;
63 }
64
65
66 void WardenEntity::SetMetadataValue(const int index, const std::any& value)
67 {
68 if (index < hierarchy_metadata_count)
69 {
71 }
73 {
74 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
76 }
77 }
78
80 {
81 std::shared_lock<std::shared_mutex> lock(entity_mutex);
82 return std::any_cast<int>(metadata.at("client_anger_level"));
83 }
84
85
86 void WardenEntity::SetClientAngerLevel(const int client_anger_level)
87 {
88 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
89 metadata["client_anger_level"] = client_anger_level;
90 }
91
92
94 {
95 return 0.9;
96 }
97
99 {
100 return 2.9;
101 }
102
103}
104#endif
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
int GetClientAngerLevel() const
virtual ProtocolCraft::Json::Value Serialize() const override
static constexpr int metadata_count
static std::string GetClassName()
static EntityType GetClassType()
static const std::array< std::string, metadata_count > metadata_names
virtual EntityType GetType() const override
virtual double GetHeightImpl() const override
virtual double GetWidthImpl() const override
static constexpr int hierarchy_metadata_count
virtual void SetMetadataValue(const int index, const std::any &value) override
void SetClientAngerLevel(const int client_anger_level)
virtual std::string GetName() const override
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45