Botcraft 1.21.4
Loading...
Searching...
No Matches
AbstractVillagerEntity.cpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 477 /* > 1.14 */
3
4#include <mutex>
5
6namespace Botcraft
7{
8 const std::array<std::string, AbstractVillagerEntity::metadata_count> AbstractVillagerEntity::metadata_names{ {
9 "data_unhappy_counter",
10 } };
11
13 {
14 // Initialize all metadata with default values
16 }
17
22
24 {
25 return true;
26 }
27
28
30 {
32
33 output["metadata"]["data_unhappy_counter"] = GetDataUnhappyCounter();
34
35 return output;
36 }
37
38
39 void AbstractVillagerEntity::SetMetadataValue(const int index, const std::any& value)
40 {
41 if (index < hierarchy_metadata_count)
42 {
44 }
46 {
47 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
49 }
50 }
51
53 {
54 std::shared_lock<std::shared_mutex> lock(entity_mutex);
55 return std::any_cast<int>(metadata.at("data_unhappy_counter"));
56 }
57
58
59 void AbstractVillagerEntity::SetDataUnhappyCounter(const int data_unhappy_counter)
60 {
61 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
62 metadata["data_unhappy_counter"] = data_unhappy_counter;
63 }
64
65}
66#endif
static const std::array< std::string, metadata_count > metadata_names
virtual ProtocolCraft::Json::Value Serialize() const override
virtual void SetMetadataValue(const int index, const std::any &value) override
void SetDataUnhappyCounter(const int data_unhappy_counter)
virtual bool IsAbstractVillager() const override
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
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45