Botcraft 1.21.4
Loading...
Searching...
No Matches
GoatEntity.cpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
3
4#include <mutex>
5
6namespace Botcraft
7{
8 const std::array<std::string, GoatEntity::metadata_count> GoatEntity::metadata_names{ {
9 "data_is_screaming_goat",
10#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
11 "data_has_left_horn",
12 "data_has_right_horn",
13#endif
14 } };
15
17 {
18 // Initialize all metadata with default values
20#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
23#endif
24
25 // Initialize all attributes with default values
29 }
30
35
36
37 std::string GoatEntity::GetName() const
38 {
39 return "goat";
40 }
41
43 {
44 return EntityType::Goat;
45 }
46
47
49 {
50 return "goat";
51 }
52
57
58
60 {
62
63 output["metadata"]["data_is_screaming_goat"] = GetDataIsScreamingGoat();
64#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
65 output["metadata"]["data_has_left_horn"] = GetDataHasLeftHorn();
66 output["metadata"]["data_has_right_horn"] = GetDataHasRightHorn();
67#endif
68
69 output["attributes"]["attack_damage"] = GetAttributeAttackDamageValue();
70
71 return output;
72 }
73
74
75 void GoatEntity::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_is_screaming_goat"));
92 }
93
94#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
96 {
97 std::shared_lock<std::shared_mutex> lock(entity_mutex);
98 return std::any_cast<bool>(metadata.at("data_has_left_horn"));
99 }
100
102 {
103 std::shared_lock<std::shared_mutex> lock(entity_mutex);
104 return std::any_cast<bool>(metadata.at("data_has_right_horn"));
105 }
106#endif
107
108
109 void GoatEntity::SetDataIsScreamingGoat(const bool data_is_screaming_goat)
110 {
111 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
112 metadata["data_is_screaming_goat"] = data_is_screaming_goat;
113 }
114
115#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
116 void GoatEntity::SetDataHasLeftHorn(const bool data_has_left_horn)
117 {
118 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
119 metadata["data_has_left_horn"] = data_has_left_horn;
120 }
121
122 void GoatEntity::SetDataHasRightHorn(const bool data_has_right_horn)
123 {
124 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
125 metadata["data_has_right_horn"] = data_has_right_horn;
126 }
127#endif
128
129
131 {
132 std::shared_lock<std::shared_mutex> lock(entity_mutex);
134 }
135
136
138 {
139 return 0.9;
140 }
141
143 {
144 return 1.3;
145 }
146
147}
148#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:253
std::map< std::string, std::any > metadata
Definition Entity.hpp:268
void SetDataIsScreamingGoat(const bool data_is_screaming_goat)
virtual EntityType GetType() const override
static EntityType GetClassType()
static constexpr int metadata_count
static constexpr int hierarchy_metadata_count
bool GetDataIsScreamingGoat() const
static const std::array< std::string, metadata_count > metadata_names
virtual double GetWidthImpl() const override
void SetDataHasRightHorn(const bool data_has_right_horn)
static std::string GetClassName()
virtual std::string GetName() const override
virtual double GetHeightImpl() const override
bool GetDataHasRightHorn() const
void SetDataHasLeftHorn(const bool data_has_left_horn)
double GetAttributeAttackDamageValue() const
bool GetDataHasLeftHorn() const
virtual void SetMetadataValue(const int index, const std::any &value) override
virtual ProtocolCraft::Json::Value Serialize() const 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