Botcraft 26.2
Loading...
Searching...
No Matches
LivingEntity.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
8
9#include <vector>
10#endif
11
12#include <array>
13
14namespace Botcraft
15{
16 class LivingEntity : public Entity
17 {
18 protected:
19#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
20 static constexpr int metadata_count = 7;
21#elif PROTOCOL_VERSION > 404 /* > 1.13.2 */
22 static constexpr int metadata_count = 6;
23#else
24 static constexpr int metadata_count = 5;
25#endif
26 static const std::array<std::string, metadata_count> metadata_names;
28
29 public:
31 virtual ~LivingEntity();
32
33 virtual bool IsLivingEntity() const override;
34
35 virtual ProtocolCraft::Json::Value Serialize() const override;
36
37 // Metadata stuff
38 virtual void SetMetadataValue(const int index, const std::any& value) override;
39
40 char GetDataLivingEntityFlags() const;
41 float GetDataHealthId() const;
42#if PROTOCOL_VERSION < 766 /* < 1.20.5 */
43 int GetDataEffectColorId() const;
44#else
45 std::vector<ProtocolCraft::Particle> GetDataEffectParticles() const;
46#endif
47 bool GetDataEffectAmbienceId() const;
48 int GetDataArrowCountId() const;
49#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
50 int GetDataStingerCountId() const;
51#endif
52#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
53 std::optional<Position> GetSleepingPosId() const;
54#endif
55
56 void SetDataLivingEntityFlags(const char data_living_entity_flags);
57 void SetDataHealthId(const float data_health_id);
58#if PROTOCOL_VERSION < 766 /* < 1.20.5 */
59 void SetDataEffectColorId(const int data_effect_color_id);
60#else
61 void SetDataEffectParticles(const std::vector<ProtocolCraft::Particle>& data_effect_particles);
62#endif
63 void SetDataEffectAmbienceId(const bool data_effect_ambience_id);
64 void SetDataArrowCountId(const int data_arrow_count_id);
65#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
66 void SetDataStingerCountId(const int data_stinger_count_id);
67#endif
68#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
69 void SetSleepingPosId(const std::optional<Position>& sleeping_pos_id);
70#endif
71
72 // Attribute stuff
73 std::optional<EntityAttribute> GetAttribute(const EntityAttribute::Type type) const;
74
75 void SetAttributeBaseValue(const EntityAttribute::Type type, const double value);
79 void AddAttribute(const EntityAttribute& attribute);
80
81 double GetAttributeMaxHealthValue() const;
83 double GetAttributeMovementSpeedValue() const;
84 double GetAttributeArmorValue() const;
86#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
87 double GetAttributeMaxAbsorptionValue() const;
88#endif
89#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
90 double GetAttributeStepHeightValue() const;
91 double GetAttributeScaleValue() const;
92 double GetAttributeGravityValue() const;
95 double GetAttributeJumpStrengthValue() const;
96#endif
97#if PROTOCOL_VERSION > 766 /* > 1.20.6 */
98 double GetAttributeOxygenBonusValue() const;
99 double GetAttributeBurningTimeValue() const;
104#endif
105#if PROTOCOL_VERSION > 770 /* > 1.21.5 */
106 double GetAttributeCameraDistanceValue() const;
108#endif
109#if PROTOCOL_VERSION > 774 /* > 1.21.11 */
111#endif
112#if PROTOCOL_VERSION > 775 /* > 26.1.2 */
113 double GetAttributeBouncinessValue() const;
118#endif
119
120#if PROTOCOL_VERSION < 767 /* < 1.21 */
121 // 87f46a96-686f-4796-b035-22e16ee9e038
122 static constexpr std::array<unsigned char, 16> speed_modifier_soul_speed_key = { 0x87, 0xF4, 0x6A, 0x96, 0x68, 0x6F, 0x47, 0x96, 0xB0, 0x35, 0x22, 0xE1, 0x6E, 0xE9, 0xE0, 0x38 };
123 // 1eaf83ff-7207-4596-b37a-d7a07b3ec4ce
124 static constexpr std::array<unsigned char, 16> speed_modifier_powder_snow_key = { 0x1E, 0xAF, 0x83, 0xFF, 0x72, 0x7, 0x45, 0x96, 0xB3, 0x7A, 0xD7, 0xA0, 0x7B, 0x3E, 0xC4, 0xCE };
125 // 662a6b8d-da3e-4c1c-8813-96ea6097278d
126 static constexpr std::array<unsigned char, 16> speed_modifier_sprinting_key = { 0x66, 0x2A, 0x6B, 0x8D, 0xDA, 0x3E, 0x4C, 0x1C, 0x88, 0x13, 0x96, 0xEA, 0x60, 0x97, 0x27, 0x8D };
127#else
128 inline static const std::string speed_modifier_powder_snow_key = "minecraft:powder_snow";
129 inline static const std::string speed_modifier_sprinting_key = "minecraft:sprinting";
130#endif
131
132 protected:
136 char GetDataLivingEntityFlagsImpl() const;
137#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
138 std::optional<Position> GetSleepingPosIdImpl() const;
139#endif
140#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
141 double GetAttributeStepHeightValueImpl() const;
142 double GetAttributeGravityValueImpl() const;
144#endif
145#if PROTOCOL_VERSION > 766 /* > 1.20.6 */
148#endif
149
150 protected:
151 std::map<EntityAttribute::Type, EntityAttribute> attributes;
152
153 };
154}
static constexpr int hierarchy_metadata_count
Definition Entity.hpp:62
static constexpr int metadata_count
Definition Entity.hpp:55
double GetAttributeGravityValueImpl() const
double GetAttributeMovementEfficiencyValueImpl() const
double GetAttributeFrictionModifierValue() const
char GetDataLivingEntityFlags() const
double GetAttributeStepHeightValueImpl() const
double GetAttributeExplosionKnockbackResistanceValue() const
double GetAttributeNameTagDistanceValue() const
double GetAttributeScaleValue() const
bool GetDataEffectAmbienceId() const
void RemoveAttributeModifier(const EntityAttribute::Type type, const EntityAttribute::ModifierKey &key)
double GetAttributeJumpStrengthValueImpl() const
void SetDataStingerCountId(const int data_stinger_count_id)
double GetAttributeMaxHealthValue() const
std::optional< Position > GetSleepingPosId() const
void SetAttributeModifierImpl(const EntityAttribute::Type type, const EntityAttribute::ModifierKey &key, const EntityAttribute::Modifier &modifier)
static const std::string speed_modifier_powder_snow_key
virtual bool IsLivingEntity() const override
double GetAttributeSafeFallDistanceValue() const
double GetAttributeOxygenBonusValue() const
void SetDataArrowCountId(const int data_arrow_count_id)
void ClearModifiers(const EntityAttribute::Type type)
static const std::array< std::string, metadata_count > metadata_names
double GetAttributeMaxAbsorptionValue() const
std::optional< Position > GetSleepingPosIdImpl() const
static constexpr int hierarchy_metadata_count
void SetAttributeModifier(const EntityAttribute::Type type, const EntityAttribute::ModifierKey &key, const EntityAttribute::Modifier &modifier)
void SetDataEffectAmbienceId(const bool data_effect_ambience_id)
int GetDataStingerCountId() const
std::map< EntityAttribute::Type, EntityAttribute > attributes
void SetDataLivingEntityFlags(const char data_living_entity_flags)
void RemoveAttributeModifierImpl(const EntityAttribute::Type type, const EntityAttribute::ModifierKey &key)
double GetAttributeJumpStrengthValue() const
void SetDataEffectParticles(const std::vector< ProtocolCraft::Particle > &data_effect_particles)
double GetAttributeMovementSpeedValueImpl() const
double GetAttributeMovementSpeedValue() const
void SetDataHealthId(const float data_health_id)
double GetAttributeWaterMovementEfficiencyValueImpl() const
double GetAttributeArmorToughnessValue() const
virtual ProtocolCraft::Json::Value Serialize() const override
static constexpr int metadata_count
double GetAttributeBurningTimeValue() const
char GetDataLivingEntityFlagsImpl() const
double GetAttributeGravityValue() const
int GetDataArrowCountId() const
double GetAttributeEntityInteractionRangeValue() const
double GetAttributeCameraDistanceValue() const
double GetAttributeArmorValue() const
double GetAttributeAirDragModifierValue() const
double GetAttributeStepHeightValue() const
double GetAttributeWaypointTransmitRangeValue() const
double GetAttributeBouncinessValue() const
void SetSleepingPosId(const std::optional< Position > &sleeping_pos_id)
double GetAttributeAttackKnockbackValue() const
double GetAttributeFallDamageMultiplierValue() const
double GetAttributeKnockbackResistanceValue() const
virtual void SetMetadataValue(const int index, const std::any &value) override
void AddAttribute(const EntityAttribute &attribute)
double GetAttributeMovementEfficiencyValue() const
float GetDataHealthId() const
double GetAttributeBelowNameDistanceValue() const
static const std::string speed_modifier_sprinting_key
void SetAttributeBaseValue(const EntityAttribute::Type type, const double value)
std::vector< ProtocolCraft::Particle > GetDataEffectParticles() const
double GetAttributeWaterMovementEfficiencyValue() const
std::optional< EntityAttribute > GetAttribute(const EntityAttribute::Type type) const
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45