Botcraft 1.21.4
Loading...
Searching...
No Matches
ThrowableItemProjectileEntity.cpp
Go to the documentation of this file.
2
3#include <mutex>
4
5namespace Botcraft
6{
7#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
8 const std::array<std::string, ThrowableItemProjectileEntity::metadata_count> ThrowableItemProjectileEntity::metadata_names{ {
9 "data_item_stack",
10 } };
11#endif
12
14 {
15 // Initialize all metadata with default values
16#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
18#endif
19 }
20
25
27 {
28 return true;
29 }
30
31
32#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
34 {
36
37 output["metadata"]["data_item_stack"] = GetDataItemStack().Serialize();
38
39 return output;
40 }
41
42
43 void ThrowableItemProjectileEntity::SetMetadataValue(const int index, const std::any& value)
44 {
45 if (index < hierarchy_metadata_count)
46 {
48 }
50 {
51 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
53 }
54 }
55
57 {
58 std::shared_lock<std::shared_mutex> lock(entity_mutex);
59 return std::any_cast<ProtocolCraft::Slot>(metadata.at("data_item_stack"));
60 }
61
62
64 {
65 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
66 metadata["data_item_stack"] = data_item_stack;
67 }
68#endif
69
70}
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
virtual ProtocolCraft::Json::Value Serialize() const override
virtual void SetMetadataValue(const int index, const std::any &value) override
static const std::array< std::string, metadata_count > metadata_names
void SetDataItemStack(const ProtocolCraft::Slot &data_item_stack)
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45
virtual Json::Value Serialize() const