Botcraft 1.21.5
Loading...
Searching...
No Matches
SheepEntity.cpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
3
4#include <mutex>
5
6namespace Botcraft
7{
8 const std::array<std::string, SheepEntity::metadata_count> SheepEntity::metadata_names{ {
9 "data_wool_id",
10 } };
11
13 {
14 // Initialize all metadata with default values
16
17 // Initialize all attributes with default values
20 }
21
26
27
28 std::string SheepEntity::GetName() const
29 {
30 return "sheep";
31 }
32
37
38
40 {
41 return "sheep";
42 }
43
48
49
51 {
53
54 output["metadata"]["data_wool_id"] = GetDataWoolId();
55
56 return output;
57 }
58
59
60 void SheepEntity::SetMetadataValue(const int index, const std::any& value)
61 {
62 if (index < hierarchy_metadata_count)
63 {
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<char>(metadata.at("data_wool_id"));
77 }
78
79
80 void SheepEntity::SetDataWoolId(const char data_wool_id)
81 {
82 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
83 metadata["data_wool_id"] = data_wool_id;
84 }
85
86
88 {
89 return 0.9;
90 }
91
93 {
94 return 1.3;
95 }
96
97}
98#endif
virtual void SetMetadataValue(const int index, const std::any &value) override
virtual ProtocolCraft::Json::Value Serialize() const override
std::shared_mutex entity_mutex
Definition Entity.hpp:259
std::map< std::string, std::any > metadata
Definition Entity.hpp:274
std::map< EntityAttribute::Type, EntityAttribute > attributes
virtual double GetWidthImpl() const override
static constexpr int metadata_count
virtual ProtocolCraft::Json::Value Serialize() const override
virtual double GetHeightImpl() const override
static const std::array< std::string, metadata_count > metadata_names
static constexpr int hierarchy_metadata_count
static EntityType GetClassType()
virtual std::string GetName() const override
void SetDataWoolId(const char data_wool_id)
char GetDataWoolId() const
static std::string GetClassName()
virtual void SetMetadataValue(const int index, const std::any &value) override
virtual EntityType GetType() const override
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45