Botcraft 26.3
Loading...
Searching...
No Matches
DolphinEntity.cpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
3
4namespace Botcraft
5{
7 {
8 // Initialize all metadata with default values
10#if PROTOCOL_VERSION < 770 /* < 1.21.5 */
11 SetTreasurePos(Position(0, 0, 0));
12#endif
13 SetGotFish(false);
15
16 // Initialize all attributes with default values
20 }
21
26
27
28 std::string DolphinEntity::GetName() const
29 {
30 return "dolphin";
31 }
32
37
38
40 {
41 return "dolphin";
42 }
43
48
49
51 {
52#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
54#else
56#endif
57
58#if PROTOCOL_VERSION < 770 /* < 1.21.5 */
59 output["metadata"]["treasure_pos"] = GetTreasurePos().Serialize();
60#endif
61 output["metadata"]["got_fish"] = GetGotFish();
62 output["metadata"]["moistness_level"] = GetMoistnessLevel();
63
64 output["attributes"]["attack_damage"] = GetAttributeAttackDamageValue();
65
66 return output;
67 }
68
69
70#if PROTOCOL_VERSION < 770 /* < 1.21.5 */
71 Position DolphinEntity::GetTreasurePos() const
72 {
73 return GetMetadata<Position>(BOTCRAFT_ENTITY_METADATA_INDEX("treasure_pos"));
74 }
75#endif
76
78 {
79 return GetMetadata<bool>(BOTCRAFT_ENTITY_METADATA_INDEX("got_fish"));
80 }
81
83 {
84 return GetMetadata<int>(BOTCRAFT_ENTITY_METADATA_INDEX("moistness_level"));
85 }
86
87
88#if PROTOCOL_VERSION < 770 /* < 1.21.5 */
89 void DolphinEntity::SetTreasurePos(const Position& treasure_pos)
90 {
91 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("treasure_pos"), treasure_pos);
92 }
93#endif
94
95 void DolphinEntity::SetGotFish(const bool got_fish)
96 {
97 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("got_fish"), got_fish);
98 }
99
100 void DolphinEntity::SetMoistnessLevel(const int moistness_level)
101 {
102 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("moistness_level"), moistness_level);
103 }
104
105
107 {
108 std::shared_lock<std::shared_mutex> lock(entity_mutex);
110 }
111
112
114 {
115 return 0.9;
116 }
117
119 {
120 return 0.6;
121 }
122
123}
124#endif
virtual ProtocolCraft::Json::Value Serialize() const override
virtual EntityType GetType() const override
double GetAttributeAttackDamageValue() const
virtual std::string GetName() const override
static constexpr int metadata_count
virtual double GetWidthImpl() const override
static EntityType GetClassType()
virtual double GetHeightImpl() const override
virtual ProtocolCraft::Json::Value Serialize() const override
static constexpr int hierarchy_metadata_count
void SetMoistnessLevel(const int moistness_level)
void SetGotFish(const bool got_fish)
static std::string GetClassName()
void SetMetadata(const int index, const std::any &value)
Definition Entity.cpp:366
virtual ProtocolCraft::Json::Value Serialize() const
Definition Entity.cpp:1246
std::shared_mutex entity_mutex
Definition Entity.hpp:320
std::vector< std::any > metadata
Definition Entity.hpp:335
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
Vector3< int > Position
Definition Vector3.hpp:314