96 unsigned int GetLevel(
int a_EnchantmentID)
const;
99 void SetLevel(
int a_EnchantmentID,
unsigned int a_Level);
125 static unsigned int GetLevelCap(
int a_EnchantmentID);
161 typedef std::map<int, unsigned int>
cMap;
168 cMap::const_iterator
begin()
const {
return m_Enchantments.begin(); }
169 cMap::const_iterator
end()
const {
return m_Enchantments.end(); }
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...
cEnchantments m_Enchantments
cEnchantments(void)
Creates an empty enchantments container.
cMap::const_iterator end() const
Parses and contains the parsed data Also implements data accessor functions for tree traversal and va...
static void RemoveEnchantmentWeightFromVector(cWeightedEnchantments &a_Enchantments, int a_EnchantmentID)
Remove the entire enchantment (with weight) from the vector.
void Clear(void)
Removes all enchantments.
eEnchantment
Individual enchantment IDs, corresponding to their NBT IDs: https://minecraft.gamepedia.com/Data_values#Enchantment_IDs.
unsigned int GetLevel(int a_EnchantmentID) const
Returns the level for the specified enchantment; 0 if not stored.
cMap m_Enchantments
Currently stored enchantments.
static void AddItemEnchantmentWeights(cWeightedEnchantments &a_Enchantments, short a_ItemType, int a_EnchantmentLevel)
Add enchantment weights from item to the vector.
void AddFromString(const AString &a_StringSpec)
Adds enchantments in the stringspec; if a specified enchantment already exists, overwrites it...
void SetLevel(int a_EnchantmentID, unsigned int a_Level)
Sets the level for the specified enchantment, adding it if not stored before or removing it if level ...
std::vector< cWeightedEnchantment > cWeightedEnchantments
void Add(const cEnchantments &a_Other)
Adds the enchantments contained in a_Other into this object.
bool operator!=(const cEnchantments &a_Other) const
Returns true if a_Other doesn't contain exactly the same enchantments and levels. ...
size_t Count(void)
Get the count of enchantments.
static void AddEnchantmentWeightToVector(cWeightedEnchantments &a_Enchantments, int a_Weight, int a_EnchantmentID, unsigned int a_EnchantmentLevel)
Add a enchantment with weight to the vector.
bool operator==(const cEnchantments &a_Other) const
Returns true if a_Other contains exactly the same enchantments and levels.
cMap::const_iterator begin() const
Make this class iterable.
static unsigned int GetLevelCap(int a_EnchantmentID)
Get the maximum level the enchantment can have.
static cEnchantments GetRandomEnchantmentFromVector(cWeightedEnchantments &a_Enchantments)
Gets random enchantment from Vector and returns it.
static int GetXPCostMultiplier(int a_EnchantmentID, bool FromBook)
Get the XP cost multiplier for the enchantment (for anvils).
std::map< int, unsigned int > cMap
Maps enchantment ID -> enchantment level.
AString ToString(void) const
Serializes all the enchantments into a string.
Class that stores item enchantments or stored-enchantments The enchantments may be serialized to a st...
static int StringToEnchantmentID(const AString &a_EnchantmentName)
Converts enchantment name or ID (number in string) to the numeric representation; returns -1 if encha...
static void CheckEnchantmentConflictsFromVector(cWeightedEnchantments &a_Enchantments, cEnchantments a_FirstEnchantment)
Check enchantment conflicts from enchantments from the vector.
bool IsEmpty(void) const
Returns true if there are no enchantments.
void ParseFromNBT(cEnchantments &a_Enchantments, const cParsedNBT &a_NBT, int a_EnchListTagIdx)
Reads the enchantments from the specified NBT list tag (ench or StoredEnchantments) ...
static cEnchantments SelectEnchantmentFromVector(const cWeightedEnchantments &a_Enchantments, int a_Seed)
Selects one enchantment from a Vector using cNoise.
bool CanAddEnchantment(int a_EnchantmentID) const
Returns true if the given enchantment could be legally added to this object.