Botcraft 1.21.4
Loading...
Searching...
No Matches
MinecartCommandBlockEntity.cpp
Go to the documentation of this file.
2
3#include <mutex>
4
5namespace Botcraft
6{
7 const std::array<std::string, MinecartCommandBlockEntity::metadata_count> MinecartCommandBlockEntity::metadata_names{ {
8 "data_id_command_name",
9 "data_id_last_output",
10 } };
11
13 {
14 // Initialize all metadata with default values
17 }
18
23
24
26 {
27 return "command_block_minecart";
28 }
29
34
35
37 {
38 return "command_block_minecart";
39 }
40
45
46
48 {
50
51 output["metadata"]["data_id_command_name"] = GetDataIdCommandName();
52 output["metadata"]["data_id_last_output"] = GetDataIdLastOutput().Serialize();
53
54 return output;
55 }
56
57
58 void MinecartCommandBlockEntity::SetMetadataValue(const int index, const std::any& value)
59 {
60 if (index < hierarchy_metadata_count)
61 {
63 }
65 {
66 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
68 }
69 }
70
72 {
73 std::shared_lock<std::shared_mutex> lock(entity_mutex);
74 return std::any_cast<std::string>(metadata.at("data_id_command_name"));
75 }
76
78 {
79 std::shared_lock<std::shared_mutex> lock(entity_mutex);
80 return std::any_cast<ProtocolCraft::Chat>(metadata.at("data_id_last_output"));
81 }
82
83
84 void MinecartCommandBlockEntity::SetDataIdCommandName(const std::string& data_id_command_name)
85 {
86 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
87 metadata["data_id_command_name"] = data_id_command_name;
88 }
89
91 {
92 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
93 metadata["data_id_last_output"] = data_id_last_output;
94 }
95
96
98 {
99 return 0.98;
100 }
101
103 {
104 return 0.7;
105 }
106
107}
virtual ProtocolCraft::Json::Value Serialize() const override
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
virtual EntityType GetType() const override
void SetDataIdCommandName(const std::string &data_id_command_name)
static const std::array< std::string, metadata_count > metadata_names
virtual std::string GetName() const override
void SetDataIdLastOutput(const ProtocolCraft::Chat &data_id_last_output)
virtual ProtocolCraft::Json::Value Serialize() const override
virtual void SetMetadataValue(const int index, const std::any &value) override
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45
virtual Json::Value Serialize() const