Botcraft 1.21.4
Loading...
Searching...
No Matches
AbstractIllagerEntity.cpp
Go to the documentation of this file.
2
3#include <mutex>
4
5namespace Botcraft
6{
7#if PROTOCOL_VERSION < 405 /* < 1.14 */
8 const std::array<std::string, AbstractIllagerEntity::metadata_count> AbstractIllagerEntity::metadata_names{ {
9 "has_target",
10 } };
11#endif
13 {
14#if PROTOCOL_VERSION < 405 /* < 1.14 */
15 // Initialize all metadata with default values
16 SetHasTarget(0);
17#endif
18 }
19
24
26 {
27 return true;
28 }
29
30
31#if PROTOCOL_VERSION < 405 /* < 1.14 */
33 {
35
36 output["metadata"]["has_target"] = GetHasTarget();
37
38 return output;
39 }
40
41
42 void AbstractIllagerEntity::SetMetadataValue(const int index, const std::any& value)
43 {
44 if (index < hierarchy_metadata_count)
45 {
47 }
49 {
50 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
52 }
53 }
54
55 char AbstractIllagerEntity::GetHasTarget() const
56 {
57 std::shared_lock<std::shared_mutex> lock(entity_mutex);
58 return std::any_cast<char>(metadata.at("has_target"));
59 }
60
61 void AbstractIllagerEntity::SetHasTarget(const char has_target)
62 {
63 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
64 metadata["has_target"] = has_target;
65 }
66#endif
67
68}
virtual bool IsAbstractIllager() const override
virtual ProtocolCraft::Json::Value Serialize() const
Definition Entity.cpp:1095
virtual void SetMetadataValue(const int index, const std::any &value)
Definition Entity.cpp:622
static const std::array< std::string, metadata_count > metadata_names
Definition Entity.hpp:61
std::shared_mutex entity_mutex
Definition Entity.hpp:253
std::map< std::string, std::any > metadata
Definition Entity.hpp:268
virtual ProtocolCraft::Json::Value Serialize() 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