Botcraft 1.21.4
Loading...
Searching...
No Matches
PufferfishEntity.cpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
3
4#include <mutex>
5
6namespace Botcraft
7{
8 const std::array<std::string, PufferfishEntity::metadata_count> PufferfishEntity::metadata_names{ {
9 "puff_state",
10 } };
11
13 {
14 // Initialize all metadata with default values
15 SetPuffState(0);
16 }
17
22
23
24 std::string PufferfishEntity::GetName() const
25 {
26 return "pufferfish";
27 }
28
33
34
36 {
37 return "pufferfish";
38 }
39
44
45
47 {
49
50 output["metadata"]["puff_state"] = GetPuffState();
51
52 return output;
53 }
54
55
56 void PufferfishEntity::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
70 {
71 std::shared_lock<std::shared_mutex> lock(entity_mutex);
72 return std::any_cast<int>(metadata.at("puff_state"));
73 }
74
75
76 void PufferfishEntity::SetPuffState(const int puff_state)
77 {
78 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
79 metadata["puff_state"] = puff_state;
80 }
81
82
84 {
85 return 0.7;
86 }
87
89 {
90 return 0.7;
91 }
92
93}
94#endif
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
static constexpr int metadata_count
virtual double GetHeightImpl() const override
static constexpr int hierarchy_metadata_count
virtual EntityType GetType() const override
virtual void SetMetadataValue(const int index, const std::any &value) override
virtual double GetWidthImpl() const override
static EntityType GetClassType()
void SetPuffState(const int puff_state)
virtual ProtocolCraft::Json::Value Serialize() const override
static std::string GetClassName()
virtual std::string GetName() const override
static const std::array< std::string, metadata_count > metadata_names
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45