Botcraft 1.21.4
Loading...
Searching...
No Matches
MushroomCowEntity.cpp
Go to the documentation of this file.
2
3#include <mutex>
4
5namespace Botcraft
6{
7#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
8 const std::array<std::string, MushroomCowEntity::metadata_count> MushroomCowEntity::metadata_names{ {
9 "data_type",
10 } };
11#endif
12
14 {
15#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
16 // Initialize all metadata with default values
17 SetDataType("red");
18#endif
19 }
20
25
26
27 std::string MushroomCowEntity::GetName() const
28 {
29 return "mooshroom";
30 }
31
36
37
39 {
40 return "mooshroom";
41 }
42
47
48
49#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
51 {
53
54 output["metadata"]["data_type"] = GetDataType();
55
56 return output;
57 }
58
59
60 void MushroomCowEntity::SetMetadataValue(const int index, const std::any& value)
61 {
62 if (index < hierarchy_metadata_count)
63 {
64 CowEntity::SetMetadataValue(index, value);
65 }
67 {
68 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
70 }
71 }
72
74 {
75 std::shared_lock<std::shared_mutex> lock(entity_mutex);
76 return std::any_cast<std::string>(metadata.at("data_type"));
77 }
78
79
80 void MushroomCowEntity::SetDataType(const std::string& data_type)
81 {
82 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
83 metadata["data_type"] = data_type;
84 }
85#endif
86
87
89 {
90 return 0.9;
91 }
92
94 {
95 return 1.4;
96 }
97
98}
virtual ProtocolCraft::Json::Value Serialize() const override
virtual void SetMetadataValue(const int index, const std::any &value) override
std::shared_mutex entity_mutex
Definition Entity.hpp:253
std::map< std::string, std::any > metadata
Definition Entity.hpp:268
virtual double GetWidthImpl() const override
virtual EntityType GetType() const override
void SetDataType(const std::string &data_type)
virtual double GetHeightImpl() const override
virtual std::string GetName() const override
static constexpr int hierarchy_metadata_count
static std::string GetClassName()
static const std::array< std::string, metadata_count > metadata_names
virtual void SetMetadataValue(const int index, const std::any &value) override
static constexpr int metadata_count
virtual ProtocolCraft::Json::Value Serialize() const override
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45