Botcraft 26.3
Loading...
Searching...
No Matches
AbstractArrowEntity.cpp
Go to the documentation of this file.
2
3namespace Botcraft
4{
6 {
7 // Initialize all metadata with default values
9 SetIdFlags(0);
10#if PROTOCOL_VERSION < 579 /* < 1.16 */ && PROTOCOL_VERSION > 393 /* > 1.13 */
11 SetDataOwneruuidId(std::optional<ProtocolCraft::UUID>());
12#endif
13#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
15#endif
16#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
17 SetInGround(false);
18#endif
19 }
20
25
27 {
28 return true;
29 }
30
31
33 {
34#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
36#else
38#endif
39
40 output["metadata"]["id_flags"] = GetIdFlags();
41#if PROTOCOL_VERSION < 579 /* < 1.16 */ && PROTOCOL_VERSION > 393 /* > 1.13 */
42 output["metadata"]["data_owneruuid_id"] = GetDataOwneruuidId() ? ProtocolCraft::Json::Value(GetDataOwneruuidId().value()) : ProtocolCraft::Json::Value();
43#endif
44#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
45 output["metadata"]["pierce_level"] = GetPierceLevel();
46#endif
47#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
48 output["metadata"]["in_ground"] = GetInGround();
49#endif
50
51 return output;
52 }
53
54
56 {
57 return GetMetadata<char>(BOTCRAFT_ENTITY_METADATA_INDEX("id_flags"));
58 }
59
60#if PROTOCOL_VERSION < 579 /* < 1.16 */ && PROTOCOL_VERSION > 393 /* > 1.13 */
61 std::optional<ProtocolCraft::UUID> AbstractArrowEntity::GetDataOwneruuidId() const
62 {
63 return GetMetadata<std::optional<ProtocolCraft::UUID>>(BOTCRAFT_ENTITY_METADATA_INDEX("data_owneruuid_id"));
64 }
65#endif
66
67#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
69 {
70 return GetMetadata<char>(BOTCRAFT_ENTITY_METADATA_INDEX("pierce_level"));
71 }
72#endif
73
74#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
76 {
77 return GetMetadata<bool>(BOTCRAFT_ENTITY_METADATA_INDEX("in_ground"));
78 }
79#endif
80
81
82 void AbstractArrowEntity::SetIdFlags(const char id_flags)
83 {
84 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("id_flags"), id_flags);
85 }
86
87#if PROTOCOL_VERSION < 579 /* < 1.16 */ && PROTOCOL_VERSION > 393 /* > 1.13 */
88 void AbstractArrowEntity::SetDataOwneruuidId(const std::optional<ProtocolCraft::UUID>& data_owneruuid_id)
89 {
90 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("data_owneruuid_id"), data_owneruuid_id);
91 }
92#endif
93
94#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
95 void AbstractArrowEntity::SetPierceLevel(const char pierce_level)
96 {
97 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("pierce_level"), pierce_level);
98 }
99#endif
100
101#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
102 void AbstractArrowEntity::SetInGround(const bool in_ground)
103 {
104 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("in_ground"), in_ground);
105 }
106#endif
107
108}
void SetInGround(const bool in_ground)
void SetIdFlags(const char id_flags)
virtual bool IsAbstractArrow() const override
static constexpr int hierarchy_metadata_count
virtual ProtocolCraft::Json::Value Serialize() const override
void SetPierceLevel(const char pierce_level)
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
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45
#define BOTCRAFT_ENTITY_METADATA_INDEX(name)
Definition Entity.hpp:347