the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2class AttributeModifier;
3
4// 4J: This ID is serialised into save data so new attributes must always be added after existing ones
5enum eATTRIBUTE_ID
6{
7 // 1.6.4
8 eAttributeId_GENERIC_MAXHEALTH,
9 eAttributeId_GENERIC_FOLLOWRANGE,
10 eAttributeId_GENERIC_KNOCKBACKRESISTANCE,
11 eAttributeId_GENERIC_MOVEMENTSPEED,
12 eAttributeId_GENERIC_ATTACKDAMAGE,
13 eAttributeId_HORSE_JUMPSTRENGTH,
14 eAttributeId_ZOMBIE_SPAWNREINFORCEMENTS,
15
16 // 1.8+
17 // New attributes go here
18
19 eAttributeId_COUNT
20};
21
22class Attribute
23{
24public:
25 static const int MAX_NAME_LENGTH = 64;
26
27 /**
28 * 4J: Changed this from a string name to an ID
29 * Gets the ID of this attribute, for serialization.
30 *
31 * @return Name of this attribute.
32 */
33 virtual eATTRIBUTE_ID getId() = 0;
34
35 /**
36 * Sanitizes an attribute value, making sure it's not out of range and is an acceptable amount.
37 *
38 *
39 * @param value Value to sanitize.
40 * @return Sanitized value, safe for use.
41 */
42 virtual double sanitizeValue(double value) = 0;
43
44 /**
45 * Get the default value of this attribute, to be used upon creation.
46 *
47 * @return Default value.
48 */
49 virtual double getDefaultValue() = 0;
50
51 /**
52 * Checks if this attribute should be synced to the client.
53 *
54 * Attributes should be serverside only unless the client needs to know about it.
55 *
56 * @return True if the client should know about this attribute.
57 */
58 virtual bool isClientSyncable() = 0;
59
60 // 4J: Added to retrieve string ID for attribute
61 static int getName(eATTRIBUTE_ID id);
62
63protected:
64 static const int AttributeNames [];
65};
66
67#ifdef __ORBIS__
68typedef unordered_map<eATTRIBUTE_ID, AttributeModifier *, std::hash<int>> attrAttrModMap;
69#else
70typedef unordered_map<eATTRIBUTE_ID, AttributeModifier *> attrAttrModMap;
71#endif