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