Botcraft 1.21.4
Loading...
Searching...
No Matches
RabbitEntity.cpp
Go to the documentation of this file.
2
3#include <mutex>
4
5namespace Botcraft
6{
7 const std::array<std::string, RabbitEntity::metadata_count> RabbitEntity::metadata_names{ {
8 "data_type_id",
9 } };
10
12 {
13 // Initialize all metadata with default values
15
16 // Initialize all attributes with default values
19#if PROTOCOL_VERSION > 766 /* > 1.20.6 */
21#endif
22 }
23
28
29
30 std::string RabbitEntity::GetName() const
31 {
32 return "rabbit";
33 }
34
39
40
42 {
43 return "rabbit";
44 }
45
50
51
53 {
55
56 output["metadata"]["data_type_id"] = GetDataTypeId();
57
58#if PROTOCOL_VERSION > 766 /* > 1.20.6 */
59 output["attribute"]["attack_damage"] = GetAttributeAttackDamageValue();
60#endif
61
62 return output;
63 }
64
65
66 void RabbitEntity::SetMetadataValue(const int index, const std::any& value)
67 {
68 if (index < hierarchy_metadata_count)
69 {
71 }
73 {
74 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
76 }
77 }
78
80 {
81 std::shared_lock<std::shared_mutex> lock(entity_mutex);
82 return std::any_cast<int>(metadata.at("data_type_id"));
83 }
84
85
86 void RabbitEntity::SetDataTypeId(const int data_type_id)
87 {
88 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
89 metadata["data_type_id"] = data_type_id;
90 }
91
92#if PROTOCOL_VERSION > 766 /* > 1.20.6 */
94 {
95 std::shared_lock<std::shared_mutex> lock(entity_mutex);
97 }
98#endif
99
100
102 {
103 return 0.4;
104 }
105
107 {
108 return 0.5;
109 }
110
111}
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
std::map< EntityAttribute::Type, EntityAttribute > attributes
static const std::array< std::string, metadata_count > metadata_names
void SetDataTypeId(const int data_type_id)
virtual double GetHeightImpl() const override
virtual void SetMetadataValue(const int index, const std::any &value) override
static constexpr int metadata_count
virtual double GetWidthImpl() const override
virtual std::string GetName() const override
static EntityType GetClassType()
static std::string GetClassName()
double GetAttributeAttackDamageValue() const
virtual EntityType GetType() const override
virtual ProtocolCraft::Json::Value Serialize() const override
static constexpr int hierarchy_metadata_count
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45