Botcraft 26.3
Loading...
Searching...
No Matches
SulfurCubeEntity.cpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 775 /* > 26.1.2 */
4
5namespace Botcraft
6{
8 {
9 // Initialize all metadata with default values
11 SetMaxFuse(-1);
12 SetFromBucket(false);
13
14 // Initialize all attributes with default values
16 }
17
22
23
24 std::string SulfurCubeEntity::GetName() const
25 {
26 return "sulfur_cube";
27 }
28
33
34
36 {
37 return "sulfur_cube";
38 }
39
44
45
47 {
49
50 output["metadata"]["max_fuse"] = GetMaxFuse();
51 output["metadata"]["from_bucket"] = GetFromBucket();
52
53 output["attributes"]["tempt_range"] = GetAttributeTemptRangeValue();
54
55 return output;
56 }
57
58
60 {
61 return GetMetadata<int>(BOTCRAFT_ENTITY_METADATA_INDEX("max_fuse"));
62 }
63
65 {
66 return GetMetadata<bool>(BOTCRAFT_ENTITY_METADATA_INDEX("from_bucket"));
67 }
68
69
70 void SulfurCubeEntity::SetMaxFuse(const int max_fuse)
71 {
72 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("max_fuse"), max_fuse);
73 }
74
75 void SulfurCubeEntity::SetFromBucket(const bool from_bucket)
76 {
77 SetMetadata(BOTCRAFT_ENTITY_METADATA_INDEX("from_bucket"), from_bucket);
78 }
79
80
82 {
83 std::shared_lock<std::shared_mutex> lock(entity_mutex);
85 }
86
87
88 void SulfurCubeEntity::SizeChanged(const int new_size)
89 {
92 if (it != attributes.end())
93 {
94 it->second.SetBaseValue(static_cast<double>(new_size) * 4.0);
95 }
96 else
97 {
98 LOG_WARNING("Trying to set attribute base value for " << EntityAttribute::Type::MaxHealth << " for a sulfur cube but it doesn't have this attribute");
99 }
100 }
101
103 {
104 return 0.49;
105 }
106
108 {
109 return 0.49;
110 }
111
112}
113#endif
#define LOG_WARNING(osstream)
Definition Logger.hpp:44
virtual void SizeChanged(const int new_size)
virtual ProtocolCraft::Json::Value Serialize() const override
void SetMetadata(const int index, const std::any &value)
Definition Entity.cpp:366
std::shared_mutex entity_mutex
Definition Entity.hpp:320
std::vector< std::any > metadata
Definition Entity.hpp:335
std::map< EntityAttribute::Type, EntityAttribute > attributes
virtual double GetHeightImpl() const override
double GetAttributeTemptRangeValue() const
virtual EntityType GetType() const override
virtual double GetWidthImpl() const override
virtual ProtocolCraft::Json::Value Serialize() const override
void SetMaxFuse(const int max_fuse)
static EntityType GetClassType()
static constexpr int hierarchy_metadata_count
void SetFromBucket(const bool from_bucket)
static constexpr int metadata_count
virtual void SizeChanged(const int new_size) override
virtual std::string GetName() const override
static std::string GetClassName()
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