Botcraft 26.3
Loading...
Searching...
No Matches
CreakingEntity.cpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
3
4namespace Botcraft
5{
30
35
36
37 std::string CreakingEntity::GetName() const
38 {
39 return "creaking";
40 }
41
46
47
49 {
50 return "creaking";
51 }
52
57
58
60 {
62
63 output["metadata"]["can_move"] = GetCanMove();
64 output["metadata"]["is_active"] = GetIsActive();
65#if PROTOCOL_VERSION > 768 /* > 1.21.3 */
66 output["metadata"]["is_tearing_down"] = GetIsTearingDown();
67 const std::optional<Position> home_pos = GetHomePos();
68 output["metadata"]["home_pos"] = home_pos.has_value() ? home_pos.value().Serialize() : ProtocolCraft::Json::Value(nullptr);
69#endif
70
71
72 return output;
73 }
74
75
77 {
78 return GetMetadata<bool>(BOTCRAFT_ENTITY_METADATA_INDEX("can_move"));
79 }
80
82 {
83 return GetMetadata<bool>(BOTCRAFT_ENTITY_METADATA_INDEX("is_active"));
84 }
85
86#if PROTOCOL_VERSION > 768 /* > 1.21.3 */
88 {
89 return GetMetadata<bool>(BOTCRAFT_ENTITY_METADATA_INDEX("is_tearing_down"));
90 }
91
92 std::optional<Position> CreakingEntity::GetHomePos() const
93 {
94 return GetMetadata<std::optional<Position>>(BOTCRAFT_ENTITY_METADATA_INDEX("home_pos"));
95 }
96#endif
97
98
99 void CreakingEntity::SetCanMove(const bool can_move)
100 {
101 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("can_move"), can_move);
102 }
103
104 void CreakingEntity::SetIsActive(const bool is_active)
105 {
106 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("is_active"), is_active);
107 }
108
109#if PROTOCOL_VERSION > 768 /* > 1.21.3 */
110 void CreakingEntity::SetIsTearingDown(const bool is_tearing_down)
111 {
112 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("is_tearing_down"), is_tearing_down);
113 }
114
115 void CreakingEntity::SetHomePos(const std::optional<Position>& home_pos)
116 {
117 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("home_pos"), home_pos);
118 }
119#endif
120
121
123 {
124 return 0.9;
125 }
126
128 {
129 return 2.7;
130 }
131
132}
133#endif
std::optional< Position > GetHomePos() const
virtual EntityType GetType() const override
static std::string GetClassName()
virtual double GetWidthImpl() const override
virtual std::string GetName() const override
static constexpr int hierarchy_metadata_count
void SetHomePos(const std::optional< Position > &home_pos)
static EntityType GetClassType()
virtual double GetHeightImpl() const override
virtual ProtocolCraft::Json::Value Serialize() const override
static constexpr int metadata_count
void SetCanMove(const bool can_move)
void SetIsTearingDown(const bool is_tearing_down)
void SetIsActive(const bool is_active)
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
virtual ProtocolCraft::Json::Value Serialize() 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