Botcraft 26.3
Loading...
Searching...
No Matches
OcelotEntity.cpp
Go to the documentation of this file.
2
3namespace Botcraft
4{
6 {
7 // Initialize all metadata with default values
9#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
10 SetDataTrusting(false);
11#else
12 SetDataTypeId(0);
13#endif
14
15 // Initialize all attributes with default values
19 }
20
25
26
27 std::string OcelotEntity::GetName() const
28 {
29 return "ocelot";
30 }
31
36
37
39 {
40 return "ocelot";
41 }
42
47
48
50 {
52
53#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
54 output["metadata"]["data_trusting"] = GetDataTrusting();
55#else
56 output["metadata"]["data_type_id"] = GetDataTypeId();
57#endif
58
59 output["attributes"]["attack_damage"] = GetAttributeAttackDamageValue();
60
61 return output;
62 }
63
64
65#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
67 {
68 return GetMetadata<bool>(BOTCRAFT_ENTITY_METADATA_INDEX("data_trusting"));
69 }
70
71
72 void OcelotEntity::SetDataTrusting(const bool data_trusting)
73 {
74 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("data_trusting"), data_trusting);
75 }
76#else
77 int OcelotEntity::GetDataTypeId() const
78 {
79 return GetMetadata<int>(BOTCRAFT_ENTITY_METADATA_INDEX("data_type_id"));
80 }
81
82
83 void OcelotEntity::SetDataTypeId(const int data_type_id)
84 {
85 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("data_type_id"), data_type_id);
86 }
87#endif
88
89
91 {
92 std::shared_lock<std::shared_mutex> lock(entity_mutex);
94 }
95
96
98 {
99 return 0.6;
100 }
101
103 {
104 return 0.7;
105 }
106
107}
virtual ProtocolCraft::Json::Value Serialize() const override
void SetMetadata(const int index, const std::any &value)
Definition Entity.cpp:366
std::shared_mutex entity_mutex
Definition Entity.hpp:320
std::vector< std::any > metadata
Definition Entity.hpp:335
std::map< EntityAttribute::Type, EntityAttribute > attributes
virtual ProtocolCraft::Json::Value Serialize() const override
bool GetDataTrusting() const
double GetAttributeAttackDamageValue() const
virtual std::string GetName() const override
static EntityType GetClassType()
virtual EntityType GetType() const override
static constexpr int metadata_count
void SetDataTrusting(const bool data_trusting)
virtual double GetHeightImpl() const override
static constexpr int hierarchy_metadata_count
static std::string GetClassName()
virtual double GetWidthImpl() const override
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45
#define BOTCRAFT_ENTITY_METADATA_INDEX(name)
Definition Entity.hpp:347