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