Botcraft 26.3
Loading...
Searching...
No Matches
PlayerEntity.hpp
Go to the documentation of this file.
1#pragma once
2
3#if PROTOCOL_VERSION < 773 /* < 1.21.9 */
6#else
8#endif
9
10namespace Botcraft
11{
12#if PROTOCOL_VERSION < 773 /* < 1.21.9 */
13 class PlayerEntity : public LivingEntity
14#else
16#endif
17 {
18 private:
19 static constexpr std::array metadata_names{
20 std::string_view("data_player_absorption_id"),
21 std::string_view("data_score_id"),
22#if PROTOCOL_VERSION < 773 /* < 1.21.9 */
23 std::string_view("data_player_mode_customisation"),
24 std::string_view("data_player_main_hand"),
25 std::string_view("data_shoulder_left"),
26 std::string_view("data_shoulder_right"),
27#else
28 std::string_view("data_shoulder_parrot_left"),
29 std::string_view("data_shoulder_parrot_right"),
30#endif
31 };
32 protected:
33 static constexpr int metadata_count = static_cast<int>(metadata_names.size());
34#if PROTOCOL_VERSION < 773 /* < 1.21.9 */
36#else
38#endif
39
40 public:
42 virtual ~PlayerEntity();
43
44 // Object related stuff
45 /// @brief Get the name of this entity TYPE as a string. For player name see NetworkManager::GetMyName()
46 virtual std::string GetName() const override;
47 virtual EntityType GetType() const override;
48
49#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
50 using Entity::GetCollider; // Required as otherwise GetCollider(Pose) would be found and stop the search for a GetCollider match
51 AABB GetCollider(const Pose pose) const;
52 using Entity::GetHeight; // Required as otherwise GetHeight(Pose) would be found and stop the search for a GetHeight match
53 double GetHeight(const Pose pose) const;
54 using Entity::GetWidth; // Required as otherwise GetWidth(Pose) would be found and stop the search for a GetWidth match
55 double GetWidth(const Pose pose) const;
56#endif
57 double GetEyeHeight() const;
58
59 // Static stuff, for easier comparison
60 static std::string GetClassName();
61 static EntityType GetClassType();
62
63
64 virtual ProtocolCraft::Json::Value Serialize() const override;
65
66 // Metadata stuff
67 float GetDataPlayerAbsorptionId() const;
68 int GetDataScoreId() const;
69#if PROTOCOL_VERSION < 773 /* < 1.21.9 */
71 char GetDataPlayerMainHand() const;
72 ProtocolCraft::NBT::Value GetDataShoulderLeft() const;
73 ProtocolCraft::NBT::Value GetDataShoulderRight() const;
74#else
75 std::optional<int> GetDataShoulderParrotLeft() const;
76 std::optional<int> GetDataShoulderParrotRight() const;
77#endif
78
79 void SetDataPlayerAbsorptionId(const float data_player_absorption_id);
80 void SetDataScoreId(const int data_score_id);
81#if PROTOCOL_VERSION < 773 /* < 1.21.9 */
82 void SetDataPlayerModeCustomisation(const char data_player_mode_customisation);
83 void SetDataPlayerMainHand(const char data_player_main_hand);
84 void SetDataShoulderLeft(const ProtocolCraft::NBT::Value& data_shoulder_left);
85 void SetDataShoulderRight(const ProtocolCraft::NBT::Value& data_shoulder_right);
86#else
87 void SetDataShoulderParrotLeft(const std::optional<int>& data_shoulder_parrot_left);
88 void SetDataShoulderParrotRight(const std::optional<int>& data_shoulder_parrot_right);
89#endif
90
91 virtual bool IsRemotePlayer() const override;
92
93 // Attribute stuff
94 double GetAttributeAttackDamageValue() const;
95 double GetAttributeAttackSpeedValue() const;
96 double GetAttributeLuckValue() const;
97#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
99#if PROTOCOL_VERSION < 775 /* < 26.1 */
101#endif
103#endif
104#if PROTOCOL_VERSION > 766 /* > 1.20.6 */
109#endif
110#if PROTOCOL_VERSION > 770 /* > 1.21.5 */
112#endif
113
114 protected:
115 virtual double GetEyeHeightImpl() const;
116 virtual double GetWidthImpl() const override;
117 virtual double GetHeightImpl() const override;
118#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
119 using Entity::GetColliderImpl; // Required as otherwise GetColliderImpl(Pose) would be found and stop the search for a GetColliderImpl match
120 AABB GetColliderImpl(const Pose pose) const;
121#endif
122#if PROTOCOL_VERSION > 766 /* > 1.20.6 */
124#endif
125
126 };
127}
static constexpr int metadata_count
char GetDataPlayerModeCustomisation() const
static constexpr int hierarchy_metadata_count
void SetDataPlayerModeCustomisation(const char data_player_mode_customisation)
int GetDataPlayerMainHand() const
void SetDataPlayerMainHand(const int data_player_main_hand)
double GetHeight() const
Definition Entity.cpp:349
AABB GetCollider() const
Definition Entity.cpp:337
double GetWidth() const
Definition Entity.cpp:343
AABB GetColliderImpl() const
Definition Entity.cpp:2233
static constexpr int hierarchy_metadata_count
static constexpr int metadata_count
double GetAttributeEntityInteractionRangeValue() const
double GetAttributePlayerBlockBreakSpeedValue() const
double GetAttributeAttackSpeedValue() const
std::optional< int > GetDataShoulderParrotRight() const
void SetDataPlayerAbsorptionId(const float data_player_absorption_id)
double GetHeight() const
Definition Entity.cpp:349
virtual double GetWidthImpl() const override
static constexpr std::array metadata_names
double GetAttributePlayerSweepingDamageRatioValue() const
static constexpr int hierarchy_metadata_count
void SetDataShoulderParrotLeft(const std::optional< int > &data_shoulder_parrot_left)
AABB GetCollider() const
Definition Entity.cpp:337
virtual double GetHeightImpl() const override
double GetWidth() const
Definition Entity.cpp:343
float GetDataPlayerAbsorptionId() const
void SetDataShoulderParrotRight(const std::optional< int > &data_shoulder_parrot_right)
virtual std::string GetName() const override
Get the name of this entity TYPE as a string. For player name see NetworkManager::GetMyName()
virtual EntityType GetType() const override
double GetAttributeLuckValue() const
double GetAttributePlayerSneakingSpeedValueImpl() const
std::optional< int > GetDataShoulderParrotLeft() const
double GetAttributePlayerBlockInteractionRangeValue() const
virtual ProtocolCraft::Json::Value Serialize() const override
virtual bool IsRemotePlayer() const override
static constexpr int metadata_count
AABB GetColliderImpl() const
Definition Entity.cpp:2233
static EntityType GetClassType()
void SetDataScoreId(const int data_score_id)
double GetAttributePlayerSubmergedMiningSpeedValue() const
static std::string GetClassName()
double GetEyeHeight() const
virtual double GetEyeHeightImpl() const
double GetAttributePlayerMiningEfficiencyValue() const
double GetAttributePlayerSneakingSpeedValue() const
double GetAttributeAttackDamageValue() const
double GetAttributeWaypointReceiveRangeValue() const
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45