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)
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 LOGWARNING(std::string_view a_Format, const Args &... args)
void ParseFromNBT(cEnchantments &a_Enchantments, const cParsedNBT &a_NBT, int a_EnchListTagIdx)
Reads the enchantments from the specified NBT list tag (ench or StoredEnchantments)
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...
Class that stores item enchantments or stored-enchantments The enchantments may be serialized to a st...
cMap m_Enchantments
Currently stored enchantments.
void Clear(void)
Removes all enchantments.
Parses and contains the parsed data Also implements data accessor functions for tree traversal and va...
int GetNextSibling(int a_Tag) const
Returns the next sibling of the specified tag, or -1 if none.
Int16 GetShort(int a_Tag) const
Returns the value stored in a Short tag.
int GetFirstChild(int a_Tag) const
Returns the first child of the specified tag, or -1 if none / not applicable.
AString GetName(int a_Tag) const
Returns the tag's name.
eTagType GetType(int a_Tag) const
eTagType GetChildrenType(int a_Tag) const
Returns the children type for a List tag; undefined on other tags.
void AddShort(const AString &a_Name, Int16 a_Value)
void BeginList(const AString &a_Name, eTagType a_ChildrenType)
void BeginCompound(const AString &a_Name)