Botcraft 1.21.4
Loading...
Searching...
No Matches
ThrownTridentEntity.cpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
3
4#include <mutex>
5
6namespace Botcraft
7{
8 const std::array<std::string, ThrownTridentEntity::metadata_count> ThrownTridentEntity::metadata_names{ {
9 "id_loyalty",
10#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
11 "id_foil",
12#endif
13 } };
14
16 {
17 // Initialize all metadata with default values
18 SetIdLoyalty(0);
19#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
20 SetIdFoil(false);
21#endif
22 }
23
28
29
30 std::string ThrownTridentEntity::GetName() const
31 {
32 return "trident";
33 }
34
39
40
42 {
43 return "trident";
44 }
45
50
51
53 {
55
56 output["metadata"]["id_loyalty"] = GetIdLoyalty();
57#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
58 output["metadata"]["id_foil"] = GetIdFoil();
59#endif
60
61 return output;
62 }
63
64
65 void ThrownTridentEntity::SetMetadataValue(const int index, const std::any& value)
66 {
67 if (index < hierarchy_metadata_count)
68 {
70 }
72 {
73 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
75 }
76 }
77
79 {
80 std::shared_lock<std::shared_mutex> lock(entity_mutex);
81 return std::any_cast<char>(metadata.at("id_loyalty"));
82 }
83
84#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
86 {
87 std::shared_lock<std::shared_mutex> lock(entity_mutex);
88 return std::any_cast<bool>(metadata.at("id_foil"));
89 }
90#endif
91
92
93 void ThrownTridentEntity::SetIdLoyalty(const char id_loyalty)
94 {
95 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
96 metadata["id_loyalty"] = id_loyalty;
97 }
98
99#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
100 void ThrownTridentEntity::SetIdFoil(const bool id_foil)
101 {
102 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
103 metadata["id_foil"] = id_foil;
104 }
105#endif
106
107
109 {
110 return 0.5;
111 }
112
114 {
115 return 0.5;
116 }
117
118}
119#endif
virtual void SetMetadataValue(const int index, const std::any &value) override
virtual ProtocolCraft::Json::Value Serialize() const override
std::shared_mutex entity_mutex
Definition Entity.hpp:253
std::map< std::string, std::any > metadata
Definition Entity.hpp:268
static const std::array< std::string, metadata_count > metadata_names
void SetIdFoil(const bool id_foil)
virtual std::string GetName() const override
void SetIdLoyalty(const char id_loyalty)
virtual void SetMetadataValue(const int index, const std::any &value) override
virtual double GetHeightImpl() const override
virtual double GetWidthImpl() const override
virtual EntityType GetType() const override
static constexpr int hierarchy_metadata_count
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