Botcraft 26.1.2
Loading...
Searching...
No Matches
ChickenEntity.cpp
Go to the documentation of this file.
2
3#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
4#include <mutex>
5#endif
6
7namespace Botcraft
8{
9#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
10 const std::array<std::string, ChickenEntity::metadata_count> ChickenEntity::metadata_names{ {
11 "data_variant_id",
12#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
13 "data_sound_variant_id",
14#endif
15 }};
16#endif
17
19 {
20#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
22#endif
23#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
25#endif
26 // Initialize all attributes with default values
29 }
30
35
36
37 std::string ChickenEntity::GetName() const
38 {
39 return "chicken";
40 }
41
46
47
49 {
50 return "chicken";
51 }
52
57
58#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
60 {
62 output["metadata"]["data_variant_id"] = GetDataVariantId();
63#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
64 output["metadata"]["data_sound_variant_id"] = GetDataSoundVariantId();
65#endif
66
67 return output;
68 }
69
70 void ChickenEntity::SetMetadataValue(const int index, const std::any& value)
71 {
72 if (index < hierarchy_metadata_count)
73 {
75 }
77 {
78 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
80 }
81 }
82
84 {
85 std::shared_lock<std::shared_mutex> lock(entity_mutex);
86 return std::any_cast<int>(metadata.at("data_variant_id"));
87 }
88
89#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
91 {
92 std::shared_lock<std::shared_mutex> lock(entity_mutex);
93 return std::any_cast<int>(metadata.at("data_sound_variant_id"));
94 }
95#endif
96
97
98 void ChickenEntity::SetDataVariantId(const int data_variant_id)
99 {
100 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
101 metadata["data_variant_id"] = data_variant_id;
102 }
103
104#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
105 void ChickenEntity::SetDataSoundVariantId(const int data_sound_variant_id)
106 {
107 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
108 metadata["data_sound_variant_id"] = data_sound_variant_id;
109 }
110#endif
111#endif
112
114 {
115 return 0.4;
116 }
117
119 {
120 return 0.7;
121 }
122
123}
virtual void SetMetadataValue(const int index, const std::any &value) override
virtual ProtocolCraft::Json::Value Serialize() const override
virtual ProtocolCraft::Json::Value Serialize() const override
int GetDataSoundVariantId() const
virtual std::string GetName() const override
static constexpr int hierarchy_metadata_count
static constexpr int metadata_count
void SetDataVariantId(const int data_variant_id)
virtual double GetWidthImpl() const override
static EntityType GetClassType()
void SetDataSoundVariantId(const int data_sound_variant_id)
static std::string GetClassName()
virtual void SetMetadataValue(const int index, const std::any &value) override
virtual double GetHeightImpl() const override
static const std::array< std::string, metadata_count > metadata_names
virtual EntityType GetType() const override
std::shared_mutex entity_mutex
Definition Entity.hpp:267
std::map< std::string, std::any > metadata
Definition Entity.hpp:282
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