Botcraft 26.3
Loading...
Searching...
No Matches
CushionEntity.cpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 776 /* > 26.2 */
3
4#include <mutex>
5
6namespace Botcraft
7{
8 const std::array<std::string, CushionEntity::metadata_count> CushionEntity::metadata_names{ {
9 "data_color",
10 } };
11
13 {
14 // Initialize all metadata with default values
15 SetDataColor(0);
16 }
17
22
23
24 std::string CushionEntity::GetName() const
25 {
26 return "cushion";
27 }
28
33
34
36 {
37 return "cushion";
38 }
39
44
45
47 {
49
50 output["metadata"]["data_color"] = GetDataColor();
51
52 return output;
53 }
54
55
56 void CushionEntity::SetMetadataValue(const int index, const std::any& value)
57 {
58 if (index < hierarchy_metadata_count)
59 {
61 }
63 {
64 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
66 }
67 }
68
69
71 {
72 std::shared_lock<std::shared_mutex> lock(entity_mutex);
73 return std::any_cast<int>(metadata.at("data_color"));
74 }
75
76
77 void CushionEntity::SetDataColor(const int data_color)
78 {
79 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
80 metadata["data_color"] = data_color;
81 }
82
83
85 {
86 return 1.0;
87 }
88
90 {
91 return 0.25;
92 }
93
94}
95#endif
virtual double GetWidthImpl() const override
virtual EntityType GetType() const override
void SetDataColor(const int data_color)
static EntityType GetClassType()
static constexpr int metadata_count
virtual ProtocolCraft::Json::Value Serialize() const override
static const std::array< std::string, metadata_count > metadata_names
virtual std::string GetName() const override
static constexpr int hierarchy_metadata_count
virtual double GetHeightImpl() const override
static std::string GetClassName()
virtual void SetMetadataValue(const int index, const std::any &value) override
virtual ProtocolCraft::Json::Value Serialize() const
Definition Entity.cpp:1256
virtual void SetMetadataValue(const int index, const std::any &value)
Definition Entity.cpp:783
std::shared_mutex entity_mutex
Definition Entity.hpp:270
std::map< std::string, std::any > metadata
Definition Entity.hpp:285
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45