Botcraft 26.1.2
Loading...
Searching...
No Matches
TadpoleEntity.cpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
3
4#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
5#include <mutex>
6#endif
7
8namespace Botcraft
9{
10#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
11 const std::array<std::string, TadpoleEntity::metadata_count> TadpoleEntity::metadata_names{ {
12 "age_locked",
13 } };
14#endif
15
17 {
18 // Initialize all metadata with default values
19#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
20 SetAgeLocked(false);
21#endif
22
23 // Initialize all attributes with default values
26 }
27
32
33
34 std::string TadpoleEntity::GetName() const
35 {
36 return "tadpole";
37 }
38
43
44
46 {
47 return "tadpole";
48 }
49
54
55
56#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
58 {
60
61 output["metadata"]["age_locked"] = GetAgeLocked();
62
63 return output;
64 }
65
66
67 void TadpoleEntity::SetMetadataValue(const int index, const std::any& value)
68 {
69 if (index < hierarchy_metadata_count)
70 {
72 }
74 {
75 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
77 }
78 }
79
80
82 {
83 std::shared_lock<std::shared_mutex> lock(entity_mutex);
84 return std::any_cast<bool>(metadata.at("age_locked"));
85 }
86
87
88 void TadpoleEntity::SetAgeLocked(const bool age_locked)
89 {
90 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
91 metadata["age_locked"] = age_locked;
92 }
93#endif
94
95
97 {
98 return 0.4;
99 }
100
102 {
103 return 0.3;
104 }
105
106}
107#endif
virtual ProtocolCraft::Json::Value Serialize() const override
virtual void SetMetadataValue(const int index, const std::any &value) override
std::shared_mutex entity_mutex
Definition Entity.hpp:267
std::map< std::string, std::any > metadata
Definition Entity.hpp:282
std::map< EntityAttribute::Type, EntityAttribute > attributes
static std::string GetClassName()
static constexpr int hierarchy_metadata_count
virtual void SetMetadataValue(const int index, const std::any &value) override
virtual double GetWidthImpl() const override
virtual std::string GetName() const override
static constexpr int metadata_count
void SetAgeLocked(const bool age_locked)
virtual ProtocolCraft::Json::Value Serialize() const override
virtual EntityType GetType() const override
static EntityType GetClassType()
virtual double GetHeightImpl() const override
static const std::array< std::string, metadata_count > metadata_names
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45