Botcraft 1.21.5
Loading...
Searching...
No Matches
ExperienceOrbEntity.cpp
Go to the documentation of this file.
2
3#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
4#include <mutex>
5#endif
6
7namespace Botcraft
8{
9#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
10 const std::array<std::string, ExperienceOrbEntity::metadata_count> ExperienceOrbEntity::metadata_names{ {
11 "data_value",
12 } };
13#endif
14
16 {
17#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
18 // Initialize all metadata with default values
19 SetDataValue(0);
20#endif
21 }
22
27
28
29 std::string ExperienceOrbEntity::GetName() const
30 {
31 return "experience_orb";
32 }
33
38
39
41 {
42 return "experience_orb";
43 }
44
49
50#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
52 {
54
55 output["metadata"]["data_value"] = GetDataValue();
56
57 return output;
58 }
59
60
61
62 void ExperienceOrbEntity::SetMetadataValue(const int index, const std::any& value)
63 {
64 if (index < hierarchy_metadata_count)
65 {
66 Entity::SetMetadataValue(index, value);
67 }
69 {
70 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
72 }
73 }
74
76 {
77 std::shared_lock<std::shared_mutex> lock(entity_mutex);
78 return std::any_cast<int>(metadata.at("data_value"));
79 }
80
81
82 void ExperienceOrbEntity::SetDataValue(const int data_value)
83 {
84 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
85 metadata["data_value"] = data_value;
86 }
87#endif
88
89
91 {
92 return 0.5;
93 }
94
96 {
97 return 0.5;
98 }
99
100}
virtual ProtocolCraft::Json::Value Serialize() const
Definition Entity.cpp:1151
virtual void SetMetadataValue(const int index, const std::any &value)
Definition Entity.cpp:678
std::shared_mutex entity_mutex
Definition Entity.hpp:259
std::map< std::string, std::any > metadata
Definition Entity.hpp:274
virtual ProtocolCraft::Json::Value Serialize() const override
virtual double GetHeightImpl() const override
void SetDataValue(const int data_value)
static const std::array< std::string, metadata_count > metadata_names
virtual void SetMetadataValue(const int index, const std::any &value) override
virtual std::string GetName() const override
static constexpr int hierarchy_metadata_count
virtual double GetWidthImpl() const override
virtual EntityType GetType() const override
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45