Botcraft 1.21.4
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 }
19
24
25
26 std::string EnderDragonEntity::GetName() const
27 {
28 return "ender_dragon";
29 }
30
35
36
38 {
39 return "ender_dragon";
40 }
41
46
47
49 {
51
52 output["metadata"]["data_phase"] = GetDataPhase();
53
54 return output;
55 }
56
57
58 void EnderDragonEntity::SetMetadataValue(const int index, const std::any& value)
59 {
60 if (index < hierarchy_metadata_count)
61 {
62 MobEntity::SetMetadataValue(index, value);
63 }
65 {
66 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
68 }
69 }
70
72 {
73 std::shared_lock<std::shared_mutex> lock(entity_mutex);
74 return std::any_cast<int>(metadata.at("data_phase"));
75 }
76
77
78 void EnderDragonEntity::SetDataPhase(const int data_phase)
79 {
80 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
81 metadata["data_phase"] = data_phase;
82 }
83
84
86 {
87 return 16.0;
88 }
89
91 {
92 return 8.0;
93 }
94
95}
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:253
std::map< std::string, std::any > metadata
Definition Entity.hpp:268
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