Botcraft 1.21.4
Loading...
Searching...
No Matches
AgeableMobEntity.cpp
Go to the documentation of this file.
2
3#include <mutex>
4
5namespace Botcraft
6{
7 const std::array<std::string, AgeableMobEntity::metadata_count> AgeableMobEntity::metadata_names{ {
8 "data_baby_id",
9 } };
10
12 {
13 // Initialize all metadata with default values
14 SetDataBabyId(false);
15 }
16
21
23 {
24 return true;
25 }
26
27
29 {
31
32 output["metadata"]["data_baby_id"] = GetDataBabyId();
33
34 return output;
35 }
36
37
38 void AgeableMobEntity::SetMetadataValue(const int index, const std::any& value)
39 {
40 if (index < hierarchy_metadata_count)
41 {
43 }
45 {
46 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
48 }
49 }
50
52 {
53 std::shared_lock<std::shared_mutex> lock(entity_mutex);
54 return std::any_cast<bool>(metadata.at("data_baby_id"));
55 }
56
57
58 void AgeableMobEntity::SetDataBabyId(const bool data_baby_id)
59 {
60 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
61 metadata["data_baby_id"] = data_baby_id;
62 }
63
64}
static constexpr int metadata_count
virtual ProtocolCraft::Json::Value Serialize() const override
static const std::array< std::string, metadata_count > metadata_names
static constexpr int hierarchy_metadata_count
virtual void SetMetadataValue(const int index, const std::any &value) override
virtual bool IsAgeableMob() const override
void SetDataBabyId(const bool data_baby_id)
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
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45