From d2b3011c05890652b0aa09f6e128004056a98258 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 2 Jun 2013 21:44:24 +0000 Subject: Added the possibility to specify enchantments by name in the constructor and AddFromString() function git-svn-id: http://mc-server.googlecode.com/svn/trunk@1542 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Enchantments.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source/Enchantments.h') diff --git a/source/Enchantments.h b/source/Enchantments.h index 96ebc1880..002626413 100644 --- a/source/Enchantments.h +++ b/source/Enchantments.h @@ -26,9 +26,9 @@ class cParsedNBT; /** Class that stores item enchantments or stored-enchantments The enchantments may be serialized to a stringspec and read back from such stringspec. The format for the stringspec is "id=lvl;id=lvl;id=lvl...", with an optional semicolon at the end, -mapping each enchantment's id onto its level. +mapping each enchantment's id onto its level. ID may be either a number or the enchantment name. Level value of 0 means no such enchantment, and it will not be stored in the m_Enchantments. -Serialization will never put zero-level enchantments into the stringspec. +Serialization will never put zero-level enchantments into the stringspec and will always use numeric IDs. */ class cEnchantments { @@ -84,6 +84,9 @@ public: /// Returns true if there are no enchantments bool IsEmpty(void) const; + /// Converts enchantment name to the numeric representation; returns -1 if enchantment name not found; case insensitive + static int StringToEnchantmentID(const AString & a_EnchantmentName); + // tolua_end /// Writes the enchantments into the specified NBT writer; begins with the LIST tag of the specified name ("ench" or "StoredEnchantments") -- cgit v1.2.3