Botcraft 1.21.4
Loading...
Searching...
No Matches
ParrotEntity.cpp
Go to the documentation of this file.
2
3#include <mutex>
4
5namespace Botcraft
6{
7 const std::array<std::string, ParrotEntity::metadata_count> ParrotEntity::metadata_names{ {
8 "data_variant_id",
9 } };
10
12 {
13 // Initialize all metadata with default values
15
16 // Initialize all attributes with default values
20#if PROTOCOL_VERSION > 766 /* > 1.20.6 */
22#endif
23 }
24
29
30
31 std::string ParrotEntity::GetName() const
32 {
33 return "parrot";
34 }
35
40
41
43 {
44 return "parrot";
45 }
46
51
52
54 {
56
57 output["metadata"]["data_variant_id"] = GetDataVariantId();
58
59 output["attributes"]["flying_speed"] = GetAttributeFlyingSpeedValue();
60#if PROTOCOL_VERSION > 766 /* > 1.20.6 */
61 output["attributes"]["attack_damage"] = GetAttributeAttackDamageValue();
62#endif
63
64 return output;
65 }
66
67
68 void ParrotEntity::SetMetadataValue(const int index, const std::any& value)
69 {
70 if (index < hierarchy_metadata_count)
71 {
73 }
75 {
76 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
78 }
79 }
80
82 {
83 std::shared_lock<std::shared_mutex> lock(entity_mutex);
84 return std::any_cast<int>(metadata.at("data_variant_id"));
85 }
86
87
88 void ParrotEntity::SetDataVariantId(const int data_variant_id)
89 {
90 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
91 metadata["data_variant_id"] = data_variant_id;
92 }
93
94
96 {
97 std::shared_lock<std::shared_mutex> lock(entity_mutex);
99 }
100
101#if PROTOCOL_VERSION > 766 /* > 1.20.6 */
103 {
104 std::shared_lock<std::shared_mutex> lock(entity_mutex);
106 }
107#endif
108
110 {
111 return 0.5;
112 }
113
115 {
116 return 0.9;
117 }
118
119}
virtual ProtocolCraft::Json::Value Serialize() const override
virtual void SetMetadataValue(const int index, const std::any &value) override
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 double GetWidthImpl() const override
static constexpr int hierarchy_metadata_count
virtual void SetMetadataValue(const int index, const std::any &value) override
static constexpr int metadata_count
virtual double GetHeightImpl() const override
static const std::array< std::string, metadata_count > metadata_names
virtual EntityType GetType() const override
double GetAttributeFlyingSpeedValue() const
double GetAttributeAttackDamageValue() const
virtual ProtocolCraft::Json::Value Serialize() const override
virtual std::string GetName() const override
void SetDataVariantId(const int data_variant_id)
static std::string GetClassName()
static EntityType GetClassType()
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45