Botcraft 1.21.4
Loading...
Searching...
No Matches
AbstractSkeletonEntity.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, AbstractSkeletonEntity::metadata_count> AbstractSkeletonEntity::metadata_names{ {
9 "is_swinging_arms",
10 } };
11#endif
12
14 {
15#if PROTOCOL_VERSION < 405 /* < 1.14 */
16 // Initialize all metadata with default values
17 SetIsSwingingArms(false);
18#endif
19
20 // Initialize all attributes with default values
22 }
23
28
30 {
31 return true;
32 }
33
34
35#if PROTOCOL_VERSION < 405 /* < 1.14 */
37 {
39
40 output["metadata"]["is_swinging_arms"] = GetIsSwingingArms();
41
42 return output;
43 }
44
45
46 void AbstractSkeletonEntity::SetMetadataValue(const int index, const std::any& value)
47 {
48 if (index < hierarchy_metadata_count)
49 {
51 }
53 {
54 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
56 }
57 }
58
59 bool AbstractSkeletonEntity::GetIsSwingingArms() const
60 {
61 std::shared_lock<std::shared_mutex> lock(entity_mutex);
62 return std::any_cast<bool>(metadata.at("is_swinging_arms"));
63 }
64
65
66 void AbstractSkeletonEntity::SetIsSwingingArms(const bool is_swinging_arms)
67 {
68 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
69 metadata["is_swinging_arms"] = is_swinging_arms;
70 }
71#endif
72
73}
virtual bool IsAbstractSkeleton() 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
std::map< EntityAttribute::Type, EntityAttribute > attributes
static const std::array< std::string, metadata_count > metadata_names
Definition MobEntity.hpp:11
virtual ProtocolCraft::Json::Value Serialize() const override
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45