6 #include "../Enchantments.h" 14 for (cEnchantments::cMap::const_iterator itr = a_Enchantments.
m_Enchantments.begin(), end = a_Enchantments.
m_Enchantments.end(); itr != end; ++itr)
17 a_Writer.
AddShort(
"id", static_cast<Int16>(itr->first));
18 a_Writer.
AddShort(
"lvl", static_cast<Int16>(itr->second));
35 LOGWARNING(
"%s: Invalid EnchListTag type: exp %d, got %d. Enchantments not parsed",
38 ASSERT(!
"Bad EnchListTag type");
45 LOGWARNING(
"%s: Invalid NBT list children type: exp %d, got %d. Enchantments not parsed",
48 ASSERT(!
"Bad EnchListTag children type");
52 a_Enchantments.
Clear();
61 int id = -1, lvl = -1;
72 else if (a_NBT.
GetName(ch) ==
"lvl")
78 if ((
id == -1) || (lvl <= 0))
85 a_Enchantments.
m_Enchantments[id] =
static_cast<unsigned int>(lvl);
void WriteToNBTCompound(const cEnchantments &a_Enchantments, cFastNBTWriter &a_Writer, const AString &a_ListTagName)
Writes the enchantments into the specified NBT writer; begins with the LIST tag of the specified name...
Parses and contains the parsed data Also implements data accessor functions for tree traversal and va...
void AddShort(const AString &a_Name, Int16 a_Value)
void Clear(void)
Removes all enchantments.
eTagType GetType(int a_Tag) const
cMap m_Enchantments
Currently stored enchantments.
Int16 GetShort(int a_Tag) const
Returns the value stored in a Short tag.
int GetNextSibling(int a_Tag) const
Returns the next sibling of the specified tag, or -1 if none.
void LOGWARNING(const char *a_Format, fmt::ArgList a_ArgList)
eTagType GetChildrenType(int a_Tag) const
Returns the children type for a List tag; undefined on other tags.
AString GetName(int a_Tag) const
Returns the tag's name.
Class that stores item enchantments or stored-enchantments The enchantments may be serialized to a st...
void BeginList(const AString &a_Name, eTagType a_ChildrenType)
void BeginCompound(const AString &a_Name)
void ParseFromNBT(cEnchantments &a_Enchantments, const cParsedNBT &a_NBT, int a_EnchListTagIdx)
Reads the enchantments from the specified NBT list tag (ench or StoredEnchantments) ...
int GetFirstChild(int a_Tag) const
Returns the first child of the specified tag, or -1 if none / not applicable.