Botcraft 1.21.4
Loading...
Searching...
No Matches
WitherBossEntity.cpp
Go to the documentation of this file.
2
3#include <mutex>
4
5namespace Botcraft
6{
7 const std::array<std::string, WitherBossEntity::metadata_count> WitherBossEntity::metadata_names{ {
8 "data_target_a",
9 "data_target_b",
10 "data_target_c",
11 "data_id_inv",
12 } };
13
29
34
35
36 std::string WitherBossEntity::GetName() const
37 {
38 return "wither";
39 }
40
45
46
48 {
49 return "wither";
50 }
51
56
57
59 {
61
62 output["metadata"]["data_target_a"] = GetDataTargetA();
63 output["metadata"]["data_target_b"] = GetDataTargetB();
64 output["metadata"]["data_target_c"] = GetDataTargetC();
65 output["metadata"]["data_id_inv"] = GetDataIdInv();
66
67 output["attributes"]["flying_speed"] = GetAttributeFlyingSpeedValue();
68
69 return output;
70 }
71
72
73 void WitherBossEntity::SetMetadataValue(const int index, const std::any& value)
74 {
75 if (index < hierarchy_metadata_count)
76 {
78 }
80 {
81 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
83 }
84 }
85
87 {
88 std::shared_lock<std::shared_mutex> lock(entity_mutex);
89 return std::any_cast<int>(metadata.at("data_target_a"));
90 }
91
93 {
94 std::shared_lock<std::shared_mutex> lock(entity_mutex);
95 return std::any_cast<int>(metadata.at("data_target_b"));
96 }
97
99 {
100 std::shared_lock<std::shared_mutex> lock(entity_mutex);
101 return std::any_cast<int>(metadata.at("data_target_c"));
102 }
103
105 {
106 std::shared_lock<std::shared_mutex> lock(entity_mutex);
107 return std::any_cast<int>(metadata.at("data_id_inv"));
108 }
109
110
111 void WitherBossEntity::SetDataTargetA(const int data_target_a)
112 {
113 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
114 metadata["data_target_a"] = data_target_a;
115 }
116
117 void WitherBossEntity::SetDataTargetB(const int data_target_b)
118 {
119 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
120 metadata["data_target_b"] = data_target_b;
121 }
122
123 void WitherBossEntity::SetDataTargetC(const int data_target_c)
124 {
125 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
126 metadata["data_target_c"] = data_target_c;
127 }
128
129 void WitherBossEntity::SetDataIdInv(const int data_id_inv)
130 {
131 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
132 metadata["data_id_inv"] = data_id_inv;
133 }
134
135
137 {
138 std::shared_lock<std::shared_mutex> lock(entity_mutex);
140 }
141
142
144 {
145 return 0.9;
146 }
147
149 {
150 return 3.5;
151 }
152
153}
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
virtual ProtocolCraft::Json::Value Serialize() const override
static std::string GetClassName()
virtual double GetWidthImpl() const override
static constexpr int hierarchy_metadata_count
virtual double GetHeightImpl() const override
void SetDataIdInv(const int data_id_inv)
void SetDataTargetC(const int data_target_c)
void SetDataTargetA(const int data_target_a)
virtual void SetMetadataValue(const int index, const std::any &value) override
void SetDataTargetB(const int data_target_b)
virtual EntityType GetType() const override
static EntityType GetClassType()
virtual std::string GetName() const override
double GetAttributeFlyingSpeedValue() const
static constexpr int metadata_count
static const std::array< std::string, metadata_count > metadata_names
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45