Botcraft 26.3
Loading...
Searching...
No Matches
TurtleEntity.cpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
3
4namespace Botcraft
5{
7 {
8 // Initialize all metadata with default values
10#if PROTOCOL_VERSION < 770 /* < 1.21.5 */
11 SetHomePos(Position(0, 0, 0));
12#endif
13 SetHasEgg(false);
14 SetLayingEgg(false);
15#if PROTOCOL_VERSION < 770 /* < 1.21.5 */
16 SetTravelPos(Position(0, 0, 0));
17 SetGoingHome(false);
18 SetTravelling(false);
19#endif
20
21 // Initialize all attributes with default values
24#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
26#endif
27 }
28
33
34
35 std::string TurtleEntity::GetName() const
36 {
37 return "turtle";
38 }
39
44
45
47 {
48 return "turtle";
49 }
50
55
56
58 {
60
61#if PROTOCOL_VERSION < 770 /* < 1.21.5 */
62 output["metadata"]["home_pos"] = GetHomePos().Serialize();
63#endif
64 output["metadata"]["has_egg"] = GetHasEgg();
65 output["metadata"]["laying_egg"] = GetLayingEgg();
66#if PROTOCOL_VERSION < 770 /* < 1.21.5 */
67 output["metadata"]["travel_pos"] = GetTravelPos().Serialize();
68 output["metadata"]["going_home"] = GetGoingHome();
69 output["metadata"]["travelling"] = GetTravelling();
70#endif
71
72 return output;
73 }
74
75
76#if PROTOCOL_VERSION < 770 /* < 1.21.5 */
77 Position TurtleEntity::GetHomePos() const
78 {
79 return GetMetadata<Position>(BOTCRAFT_ENTITY_METADATA_INDEX("home_pos"));
80 }
81#endif
82
84 {
85 return GetMetadata<bool>(BOTCRAFT_ENTITY_METADATA_INDEX("has_egg"));
86 }
87
89 {
90 return GetMetadata<bool>(BOTCRAFT_ENTITY_METADATA_INDEX("laying_egg"));
91 }
92
93#if PROTOCOL_VERSION < 770 /* < 1.21.5 */
94 Position TurtleEntity::GetTravelPos() const
95 {
96 return GetMetadata<Position>(BOTCRAFT_ENTITY_METADATA_INDEX("travel_pos"));
97 }
98
99 bool TurtleEntity::GetGoingHome() const
100 {
101 return GetMetadata<bool>(BOTCRAFT_ENTITY_METADATA_INDEX("going_home"));
102 }
103
104 bool TurtleEntity::GetTravelling() const
105 {
106 return GetMetadata<bool>(BOTCRAFT_ENTITY_METADATA_INDEX("travelling"));
107 }
108#endif
109
110
111#if PROTOCOL_VERSION < 770 /* < 1.21.5 */
112 void TurtleEntity::SetHomePos(const Position& home_pos)
113 {
114 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("home_pos"), home_pos);
115 }
116#endif
117
118 void TurtleEntity::SetHasEgg(const bool has_egg)
119 {
120 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("has_egg"), has_egg);
121 }
122
123 void TurtleEntity::SetLayingEgg(const bool laying_egg)
124 {
125 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("laying_egg"), laying_egg);
126 }
127
128#if PROTOCOL_VERSION < 770 /* < 1.21.5 */
129 void TurtleEntity::SetTravelPos(const Position& travel_pos)
130 {
131 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("travel_pos"), travel_pos);
132 }
133
134 void TurtleEntity::SetGoingHome(const bool going_home)
135 {
136 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("going_home"), going_home);
137 }
138
139 void TurtleEntity::SetTravelling(const bool travelling)
140 {
141 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("travelling"), travelling);
142 }
143#endif
144
145
147 {
148 return 1.2;
149 }
150
152 {
153 return 0.4;
154 }
155
156}
157#endif
virtual ProtocolCraft::Json::Value Serialize() const override
void SetMetadata(const int index, const std::any &value)
Definition Entity.cpp:366
std::vector< std::any > metadata
Definition Entity.hpp:335
std::map< EntityAttribute::Type, EntityAttribute > attributes
static EntityType GetClassType()
static constexpr int metadata_count
virtual double GetHeightImpl() const override
static std::string GetClassName()
static constexpr int hierarchy_metadata_count
virtual ProtocolCraft::Json::Value Serialize() const override
void SetLayingEgg(const bool laying_egg)
virtual double GetWidthImpl() const override
virtual EntityType GetType() const override
void SetHasEgg(const bool has_egg)
virtual std::string GetName() const override
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
Vector3< int > Position
Definition Vector3.hpp:314