Botcraft 1.21.4
Loading...
Searching...
No Matches
BoggedEntity.cpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
3
4#include <mutex>
5
6namespace Botcraft
7{
8 const std::array<std::string, BoggedEntity::metadata_count> BoggedEntity::metadata_names{ {
9 "data_sheared",
10 } };
11
13 {
14 // Initialize all metadata with default values
15 SetDataSheared(false);
16
17 // Initialize all attributes with default values
19 }
20
25
26
27 std::string BoggedEntity::GetName() const
28 {
29 return "bogged";
30 }
31
36
37
39 {
40 return "bogged";
41 }
42
47
48
50 {
52
53 output["metadata"]["data_sheared"] = GetDataSheared();
54
55 return output;
56 }
57
58
59 void BoggedEntity::SetMetadataValue(const int index, const std::any& value)
60 {
61 if (index < hierarchy_metadata_count)
62 {
64 }
66 {
67 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
69 }
70 }
71
73 {
74 std::shared_lock<std::shared_mutex> lock(entity_mutex);
75 return std::any_cast<char>(metadata.at("data_sheared"));
76 }
77
78
79 void BoggedEntity::SetDataSheared(const bool data_sheared)
80 {
81 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
82 metadata["data_sheared"] = data_sheared;
83 }
84
85
87 {
88 return 0.6;
89 }
90
92 {
93 return 1.99;
94 }
95
96}
97#endif
static const std::array< std::string, metadata_count > metadata_names
static EntityType GetClassType()
static std::string GetClassName()
virtual EntityType GetType() const override
virtual std::string GetName() const override
virtual double GetHeightImpl() const override
void SetDataSheared(const bool data_sheared)
virtual void SetMetadataValue(const int index, const std::any &value) override
bool GetDataSheared() const
virtual ProtocolCraft::Json::Value Serialize() const override
static constexpr int hierarchy_metadata_count
static constexpr int metadata_count
virtual double GetWidthImpl() const override
virtual ProtocolCraft::Json::Value Serialize() const
Definition Entity.cpp:1095
virtual void SetMetadataValue(const int index, const std::any &value)
Definition Entity.cpp:622
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
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45