summaryrefslogtreecommitdiffstats
path: root/src/Enchantments.h
diff options
context:
space:
mode:
authorLane Kolbly <lane@rscheme.org>2017-07-28 19:00:20 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2017-07-28 19:00:20 +0200
commit790e15f2e64badf62d9ba62421776c4ba0e771ed (patch)
treeb0e9c8a6100ae0b06847b7cbfaddf94586a4490e /src/Enchantments.h
parentCheck for intersection between placed blocks and entities. (#3850) (diff)
downloadcuberite-790e15f2e64badf62d9ba62421776c4ba0e771ed.tar
cuberite-790e15f2e64badf62d9ba62421776c4ba0e771ed.tar.gz
cuberite-790e15f2e64badf62d9ba62421776c4ba0e771ed.tar.bz2
cuberite-790e15f2e64badf62d9ba62421776c4ba0e771ed.tar.lz
cuberite-790e15f2e64badf62d9ba62421776c4ba0e771ed.tar.xz
cuberite-790e15f2e64badf62d9ba62421776c4ba0e771ed.tar.zst
cuberite-790e15f2e64badf62d9ba62421776c4ba0e771ed.zip
Diffstat (limited to 'src/Enchantments.h')
-rw-r--r--src/Enchantments.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/Enchantments.h b/src/Enchantments.h
index 1119f7e2f..3f7b1bfc8 100644
--- a/src/Enchantments.h
+++ b/src/Enchantments.h
@@ -45,6 +45,7 @@ public:
enum eEnchantment
{
+ // Currently missing: Frost walker, curse of binding, sweeping edge, mending, and curse of vanishing.
enchProtection = 0,
enchFireProtection = 1,
enchFeatherFalling = 2,
@@ -103,6 +104,9 @@ public:
/** Returns true if there are no enchantments */
bool IsEmpty(void) const;
+ /** Returns true if the given enchantment could be legally added to this object. Note that adding the enchantment may not actually increase the level. */
+ bool CanAddEnchantment(int a_EnchantmentID) const;
+
/** Converts enchantment name or ID (number in string) to the numeric representation; returns -1 if enchantment name not found; case insensitive */
static int StringToEnchantmentID(const AString & a_EnchantmentName);
@@ -111,6 +115,15 @@ public:
// tolua_end
+ /** Get the XP cost multiplier for the enchantment (for anvils).
+ If FromBook is true, then this function returns the XP multiplier if
+ the enchantment is coming from a book, otherwise it returns the normal
+ item multiplier. */
+ static int GetXPCostMultiplier(int a_EnchantmentID, bool FromBook);
+
+ /** Get the maximum level the enchantment can have */
+ static unsigned int GetLevelCap(int a_EnchantmentID);
+
/** Add enchantment weights from item to the vector */
static void AddItemEnchantmentWeights(cWeightedEnchantments & a_Enchantments, short a_ItemType, int a_EnchantmentLevel);
@@ -149,7 +162,12 @@ protected:
/** Currently stored enchantments */
cMap m_Enchantments;
-} ; // tolua_export
+
+public:
+ /** Make this class iterable */
+ cMap::const_iterator begin() const { return m_Enchantments.begin(); }
+ cMap::const_iterator end() const { return m_Enchantments.end(); }
+}; // tolua_export