Botcraft 26.3
Loading...
Searching...
No Matches
FireworkRocketEntity.cpp
Go to the documentation of this file.
2
3#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
5#endif
6
7namespace Botcraft
8{
10 {
11 // Initialize all metadata with default values
13#if PROTOCOL_VERSION < 766 /* < 1.20.5 */
15#else
16 const static int item_id = AssetsManager::getInstance().GetItemID("minecraft:firework_rocket");
17 ProtocolCraft::Slot default_slot;
18 default_slot.SetItemId(item_id);
19 default_slot.SetItemCount(1);
20 SetDataIdFireworksItem(default_slot);
21#endif
23#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
24 SetDataAttachedToTarget(std::optional<int>());
25 SetDataShotAtAngle(false);
26#else
28#endif
29 }
30
35
36
38 {
39 return "firework_rocket";
40 }
41
46
47
49 {
50 return "firework_rocket";
51 }
52
57
58
60 {
61#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
63#else
65#endif
66
67 output["metadata"]["data_id_fireworks_item"] = GetDataIdFireworksItem().Serialize();
68#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
69 output["metadata"]["data_attached_to_target"] = GetDataAttachedToTarget() ? ProtocolCraft::Json::Value(GetDataAttachedToTarget().value()) : ProtocolCraft::Json::Value();
70 output["metadata"]["data_shot_at_angle"] = GetDataShotAtAngle();
71#else
72 output["metadata"]["data_attached_to_target"] = GetDataAttachedToTarget();
73#endif
74
75 return output;
76 }
77
78
80 {
81 return GetMetadata<ProtocolCraft::Slot>(BOTCRAFT_ENTITY_METADATA_INDEX("data_id_fireworks_item"));
82 }
83
84#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
86 {
87 return GetMetadata<std::optional<int>>(BOTCRAFT_ENTITY_METADATA_INDEX("data_attached_to_target"));
88 }
89
91 {
92 return GetMetadata<bool>(BOTCRAFT_ENTITY_METADATA_INDEX("data_shot_at_angle"));
93 }
94#else
96 {
97 return GetMetadata<int>(BOTCRAFT_ENTITY_METADATA_INDEX("data_attached_to_target"));
98 }
99#endif
100
101
103 {
104 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("data_id_fireworks_item"), data_id_fireworks_item);
105 }
106
107#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
108 void FireworkRocketEntity::SetDataAttachedToTarget(const std::optional<int>& data_attached_to_target)
109 {
110 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("data_attached_to_target"), data_attached_to_target);
111 }
112
113 void FireworkRocketEntity::SetDataShotAtAngle(const bool data_shot_at_angle)
114 {
115 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("data_shot_at_angle"), data_shot_at_angle);
116 }
117#else
118 void FireworkRocketEntity::SetDataAttachedToTarget(const int data_attached_to_target)
119 {
120 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("data_attached_to_target"), data_attached_to_target);
121 }
122#endif
123
124
126 {
127 return 0.25;
128 }
129
131 {
132 return 0.25;
133 }
134
135}
static AssetsManager & getInstance()
ItemId GetItemID(const std::string &item_name) const
void SetMetadata(const int index, const std::any &value)
Definition Entity.cpp:366
virtual ProtocolCraft::Json::Value Serialize() const
Definition Entity.cpp:1246
std::vector< std::any > metadata
Definition Entity.hpp:335
virtual double GetHeightImpl() const override
ProtocolCraft::Slot GetDataIdFireworksItem() const
virtual ProtocolCraft::Json::Value Serialize() const override
std::optional< int > GetDataAttachedToTarget() const
virtual double GetWidthImpl() const override
void SetDataShotAtAngle(const bool data_shot_at_angle)
virtual std::string GetName() const override
void SetDataIdFireworksItem(const ProtocolCraft::Slot &data_id_fireworks_item)
virtual EntityType GetType() const override
void SetDataAttachedToTarget(const std::optional< int > &data_attached_to_target)
static constexpr int hierarchy_metadata_count
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45
virtual Json::Value Serialize() const
#define BOTCRAFT_ENTITY_METADATA_INDEX(name)
Definition Entity.hpp:347