Botcraft 26.3
Loading...
Searching...
No Matches
FrogEntity.cpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
3
4namespace Botcraft
5{
7 {
8 // Initialize all metadata with default values
11 SetDataTongueTargetId(std::optional<int>());
12
13 // Initialize all attributes with default values
17#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
19#endif
20 }
21
26
27
28 std::string FrogEntity::GetName() const
29 {
30 return "frog";
31 }
32
34 {
35 return EntityType::Frog;
36 }
37
38
40 {
41 return "frog";
42 }
43
48
49
51 {
53
54 output["metadata"]["data_variant_id"] = GetDataVariantId();
55 output["metadata"]["data_tongue_target_id"] = GetDataTongueTargetId() ? ProtocolCraft::Json::Value(GetDataTongueTargetId().value()) : ProtocolCraft::Json::Value();
56
57 output["attributes"]["attack_damage"] = GetAttributeAttackDamageValue();
58
59 return output;
60 }
61
62
64 {
65 return GetMetadata<int>(BOTCRAFT_ENTITY_METADATA_INDEX("data_variant_id"));
66 }
67
68 std::optional<int> FrogEntity::GetDataTongueTargetId() const
69 {
70 return GetMetadata<std::optional<int>>(BOTCRAFT_ENTITY_METADATA_INDEX("data_tongue_target_id"));
71 }
72
73
74 void FrogEntity::SetDataVariantId(const int data_variant_id)
75 {
76 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("data_variant_id"), data_variant_id);
77 }
78
79 void FrogEntity::SetDataTongueTargetId(const std::optional<int>& data_tongue_target_id)
80 {
81 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("data_tongue_target_id"), data_tongue_target_id);
82 }
83
84
86 {
87 std::shared_lock<std::shared_mutex> lock(entity_mutex);
89 }
90
91
93 {
94 return 0.5;
95 }
96
98 {
99 return 0.5;
100 }
101
102}
103#endif
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
void SetDataVariantId(const int data_variant_id)
std::optional< int > GetDataTongueTargetId() const
static constexpr int metadata_count
void SetDataTongueTargetId(const std::optional< int > &data_tongue_target_id)
static std::string GetClassName()
virtual ProtocolCraft::Json::Value Serialize() const override
virtual double GetHeightImpl() const override
virtual EntityType GetType() const override
static constexpr int hierarchy_metadata_count
virtual std::string GetName() const override
static EntityType GetClassType()
virtual double GetWidthImpl() const override
int GetDataVariantId() const
double GetAttributeAttackDamageValue() const
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
#define BOTCRAFT_ENTITY_METADATA_INDEX(name)
Definition Entity.hpp:347