Botcraft 1.21.4
Loading...
Searching...
No Matches
EyeOfEnderEntity.cpp
Go to the documentation of this file.
2
3#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
5#endif
6
7#include <mutex>
8
9namespace Botcraft
10{
11#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
12 const std::array<std::string, EyeOfEnderEntity::metadata_count> EyeOfEnderEntity::metadata_names{ {
13 "data_item_stack",
14 } };
15#endif
16
18 {
19 // Initialize all metadata with default values
20#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
21#if PROTOCOL_VERSION < 766 /* < 1.20.5 */
23#else
24 const static int item_id = AssetsManager::getInstance().GetItemID("minecraft:ender_eye");
25 ProtocolCraft::Slot default_slot;
26 default_slot.SetItemId(item_id);
27 default_slot.SetItemCount(1);
28 SetDataItemStack(default_slot);
29#endif
30#endif
31 }
32
37
38
39 std::string EyeOfEnderEntity::GetName() const
40 {
41 return "eye_of_ender";
42 }
43
48
49
51 {
52 return "eye_of_ender";
53 }
54
59
60
61#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
63 {
65
66 output["metadata"]["data_item_stack"] = GetDataItemStack().Serialize();
67
68 return output;
69 }
70
71
72 void EyeOfEnderEntity::SetMetadataValue(const int index, const std::any& value)
73 {
74 if (index < hierarchy_metadata_count)
75 {
76 Entity::SetMetadataValue(index, value);
77 }
79 {
80 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
82 }
83 }
84
86 {
87 std::shared_lock<std::shared_mutex> lock(entity_mutex);
88 return std::any_cast<ProtocolCraft::Slot>(metadata.at("data_item_stack"));
89 }
90
91
93 {
94 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
95 metadata["data_item_stack"] = data_item_stack;
96 }
97#endif
98
99
101 {
102 return 0.25;
103 }
104
106 {
107 return 0.25;
108 }
109
110}
static AssetsManager & getInstance()
ItemId GetItemID(const std::string &item_name) const
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 double GetWidthImpl() const override
virtual EntityType GetType() const override
virtual std::string GetName() const override
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
static constexpr int hierarchy_metadata_count
void SetDataItemStack(const ProtocolCraft::Slot &data_item_stack)
static EntityType GetClassType()
virtual double GetHeightImpl() const override
ProtocolCraft::Slot GetDataItemStack() const
static constexpr int metadata_count
static std::string GetClassName()
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45
virtual Json::Value Serialize() const