Botcraft 1.21.7
Loading...
Searching...
No Matches
EnderDragonEntity.cpp
Go to the documentation of this file.
2
3#include <mutex>
4
5namespace Botcraft
6{
7 const std::array<std::string, EnderDragonEntity::metadata_count> EnderDragonEntity::metadata_names{ {
8 "data_phase",
9 } };
10
12 {
13 // Initialize all metadata with default values
14 SetDataPhase(10);
15
16 // Initialize all attributes with default values
18#if PROTOCOL_VERSION > 770 /* > 1.21.5 */
20#endif
21 }
22
27
28
29 std::string EnderDragonEntity::GetName() const
30 {
31 return "ender_dragon";
32 }
33
38
39
41 {
42 return "ender_dragon";
43 }
44
49
50
52 {
54
55 output["metadata"]["data_phase"] = GetDataPhase();
56
57 return output;
58 }
59
60
61 void EnderDragonEntity::SetMetadataValue(const int index, const std::any& value)
62 {
63 if (index < hierarchy_metadata_count)
64 {
65 MobEntity::SetMetadataValue(index, value);
66 }
68 {
69 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
71 }
72 }
73
75 {
76 std::shared_lock<std::shared_mutex> lock(entity_mutex);
77 return std::any_cast<int>(metadata.at("data_phase"));
78 }
79
80
81 void EnderDragonEntity::SetDataPhase(const int data_phase)
82 {
83 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
84 metadata["data_phase"] = data_phase;
85 }
86
87
89 {
90 return 16.0;
91 }
92
94 {
95 return 8.0;
96 }
97
98}
virtual double GetWidthImpl() const override
static std::string GetClassName()
static constexpr int hierarchy_metadata_count
static constexpr int metadata_count
static const std::array< std::string, metadata_count > metadata_names
void SetDataPhase(const int data_phase)
virtual std::string GetName() const override
virtual void SetMetadataValue(const int index, const std::any &value) override
virtual ProtocolCraft::Json::Value Serialize() const override
virtual double GetHeightImpl() const override
virtual EntityType GetType() const override
std::shared_mutex entity_mutex
Definition Entity.hpp:261
std::map< std::string, std::any > metadata
Definition Entity.hpp:276
std::map< EntityAttribute::Type, EntityAttribute > attributes
virtual ProtocolCraft::Json::Value Serialize() const override
Definition MobEntity.cpp:34
virtual void SetMetadataValue(const int index, const std::any &value) override
Definition MobEntity.cpp:49
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45