Botcraft 1.21.8
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 }};
13#endif
14
16 {
17#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
19#endif
20 // Initialize all attributes with default values
23 }
24
29
30
31 std::string ChickenEntity::GetName() const
32 {
33 return "chicken";
34 }
35
40
41
43 {
44 return "chicken";
45 }
46
51
52#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
54 {
56 output["metadata"]["data_variant_id"] = GetDataVariantId();
57
58 return output;
59 }
60
61 void ChickenEntity::SetMetadataValue(const int index, const std::any& value)
62 {
63 if (index < hierarchy_metadata_count)
64 {
66 }
68 {
69 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
71 }
72 }
73
75 {
76 std::shared_lock<std::shared_mutex> lock(entity_mutex);
77 return std::any_cast<int>(metadata.at("data_variant_id"));
78 }
79
80
81 void ChickenEntity::SetDataVariantId(const int data_variant_id)
82 {
83 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
84 metadata["data_variant_id"] = data_variant_id;
85 }
86#endif
87
89 {
90 return 0.4;
91 }
92
94 {
95 return 0.7;
96 }
97
98}
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
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()
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:261
std::map< std::string, std::any > metadata
Definition Entity.hpp:276
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