Botcraft 26.3
Loading...
Searching...
No Matches
BoatEntity.cpp
Go to the documentation of this file.
2
3namespace Botcraft
4{
5#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
7#else
8 BoatEntity::BoatEntity(const EntityType type) : type(type)
9#endif
10 {
11 // Initialize all metadata with default values
13#if PROTOCOL_VERSION < 765 /* < 1.20.3 */
16 SetDataIdDamage(0.0f);
17#endif
18#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
19 SetDataIdType(0);
22#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
24#endif
25#endif
26 }
27
32
33
34 std::string BoatEntity::GetName() const
35 {
36 return "boat";
37 }
38
40 {
41#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
42 return EntityType::Boat;
43#else
44 return type;
45#endif
46 }
47
48
50 {
51 return "boat";
52 }
53
54#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
55 EntityType BoatEntity::GetClassType()
56 {
57 return EntityType::Boat;
58 }
59#else
60 bool BoatEntity::IsBoat() const
61 {
62 return true;
63 }
64#endif
65
66
68 {
69#if PROTOCOL_VERSION < 765 /* < 1.20.3 */
71#elif PROTOCOL_VERSION < 768 /* < 1.21.2 */
73#else
75#endif
76
77#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
78#if PROTOCOL_VERSION < 765 /* < 1.20.3 */
79 output["metadata"]["data_id_hurt"] = GetDataIdHurt();
80 output["metadata"]["data_id_hurtdir"] = GetDataIdHurtdir();
81 output["metadata"]["data_id_damage"] = GetDataIdDamage();
82#endif
83 output["metadata"]["data_id_type"] = GetDataIdType();
84 output["metadata"]["data_id_paddle_left"] = GetDataIdPaddleLeft();
85 output["metadata"]["data_id_paddle_right"] = GetDataIdPaddleRight();
86#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
87 output["metadata"]["data_id_bubble_time"] = GetDataIdBubbleTime();
88#endif
89#else
90 output["type"] = type;
91#endif
92
93 return output;
94 }
95
96
97#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
98#if PROTOCOL_VERSION < 765 /* < 1.20.3 */
100 {
101 return GetMetadata<int>(BOTCRAFT_ENTITY_METADATA_INDEX("data_id_hurt"));
102 }
103
105 {
106 return GetMetadata<int>(BOTCRAFT_ENTITY_METADATA_INDEX("data_id_hurtdir"));
107 }
108
109 float BoatEntity::GetDataIdDamage() const
110 {
111 return GetMetadata<float>(BOTCRAFT_ENTITY_METADATA_INDEX("data_id_damage"));
112 }
113#endif
114
115 int BoatEntity::GetDataIdType() const
116 {
117 return GetMetadata<int>(BOTCRAFT_ENTITY_METADATA_INDEX("data_id_type"));
118 }
119
121 {
122 return GetMetadata<bool>(BOTCRAFT_ENTITY_METADATA_INDEX("data_id_paddle_left"));
123 }
124
126 {
127 return GetMetadata<bool>(BOTCRAFT_ENTITY_METADATA_INDEX("data_id_paddle_right"));
128 }
129
130#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
132 {
133 return GetMetadata<int>(BOTCRAFT_ENTITY_METADATA_INDEX("data_id_bubble_time"));
134 }
135#endif
136
137
138#if PROTOCOL_VERSION < 765 /* < 1.20.3 */
139 void BoatEntity::SetDataIdHurt(const int data_id_hurt)
140 {
141 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("data_id_hurt"), data_id_hurt);
142 }
143
144 void BoatEntity::SetDataIdHurtdir(const int data_id_hurtdir)
145 {
146 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("data_id_hurtdir"), data_id_hurtdir);
147 }
148
149 void BoatEntity::SetDataIdDamage(const float data_id_damage)
150 {
151 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("data_id_damage"), data_id_damage);
152 }
153#endif
154
155 void BoatEntity::SetDataIdType(const int data_id_type)
156 {
157 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("data_id_type"), data_id_type);
158 }
159
160 void BoatEntity::SetDataIdPaddleLeft(const bool data_id_paddle_left)
161 {
162 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("data_id_paddle_left"), data_id_paddle_left);
163 }
164
165 void BoatEntity::SetDataIdPaddleRight(const bool data_id_paddle_right)
166 {
167 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("data_id_paddle_right"), data_id_paddle_right);
168 }
169
170#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
171 void BoatEntity::SetDataIdBubbleTime(const int data_id_bubble_time)
172 {
173 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("data_id_bubble_time"), data_id_bubble_time);
174 }
175#endif
176#endif
177
178
180 {
181 return 1.375;
182 }
183
185 {
186 return 0.5625;
187 }
188
189}
void SetDataIdPaddleRight(const bool data_id_paddle_right)
void SetDataIdBubbleTime(const int data_id_bubble_time)
virtual ProtocolCraft::Json::Value Serialize() const override
void SetDataIdPaddleLeft(const bool data_id_paddle_left)
virtual double GetWidthImpl() const override
BoatEntity(const EntityType type)
Definition BoatEntity.cpp:8
virtual ProtocolCraft::Json::Value Serialize() const override
virtual EntityType GetType() const override
static std::string GetClassName()
virtual double GetHeightImpl() const override
const EntityType type
virtual bool IsBoat() const override
static constexpr int hierarchy_metadata_count
virtual std::string GetName() const override
static constexpr int metadata_count
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
void SetDataIdHurt(const int data_id_hurt)
void SetDataIdDamage(const float data_id_damage)
float GetDataIdDamage() const
virtual ProtocolCraft::Json::Value Serialize() const override
void SetDataIdHurtdir(const int data_id_hurtdir)
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