Botcraft 1.21.4
Loading...
Searching...
No Matches
DisplayItemDisplayEntity.cpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
3
4#include <mutex>
5
6namespace Botcraft
7{
8 const std::array<std::string, DisplayItemDisplayEntity::metadata_count> DisplayItemDisplayEntity::metadata_names{ {
9 "data_item_stack_id",
10 "data_item_display_id",
11 } };
12
14 {
15 // Initialize all metadata with default values
18 }
19
24
25
27 {
28 return "item_display";
29 }
30
35
36
38 {
39 return "item_display";
40 }
41
46
47
48
50 {
52
53 output["metadata"]["data_item_stack_id"] = GetDataItemStackId().Serialize();
54 output["metadata"]["data_item_display_id"] = GetDataItemDisplayId();
55
56 return output;
57 }
58
59
60 void DisplayItemDisplayEntity::SetMetadataValue(const int index, const std::any& value)
61 {
62 if (index < hierarchy_metadata_count)
63 {
65 }
67 {
68 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
70 }
71 }
72
73
75 {
76 std::shared_lock<std::shared_mutex> lock(entity_mutex);
77 return std::any_cast<ProtocolCraft::Slot>(metadata.at("data_item_stack_id"));
78 }
79
81 {
82 std::shared_lock<std::shared_mutex> lock(entity_mutex);
83 return std::any_cast<char>(metadata.at("data_item_display_id"));
84 }
85
86
88 {
89 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
90 metadata["data_item_stack_id"] = data_item_stack_id;
91 }
92
93 void DisplayItemDisplayEntity::SetDataItemDisplayId(const char data_item_display_id)
94 {
95 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
96 metadata["data_item_display_id"] = data_item_display_id;
97 }
98
99
101 {
102 return 0.0;
103 }
104
106 {
107 return 0.0;
108 }
109
110}
111#endif
virtual ProtocolCraft::Json::Value Serialize() const override
virtual void SetMetadataValue(const int index, const std::any &value) override
ProtocolCraft::Slot GetDataItemStackId() const
virtual EntityType GetType() const override
virtual ProtocolCraft::Json::Value Serialize() const override
virtual double GetHeightImpl() const override
void SetDataItemDisplayId(const char data_item_display_id)
virtual double GetWidthImpl() const override
virtual std::string GetName() const override
void SetDataItemStackId(const ProtocolCraft::Slot &data_item_stack_id)
static const std::array< std::string, metadata_count > metadata_names
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
virtual Json::Value Serialize() const