91 size_t Count(
void)
const;
97 unsigned int GetLevel(
int a_EnchantmentID)
const;
100 void SetLevel(
int a_EnchantmentID,
unsigned int a_Level);
126 static unsigned int GetLevelCap(
int a_EnchantmentID);
162 typedef std::map<int, unsigned int>
cMap;
std::vector< cWeightedEnchantment > cWeightedEnchantments
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.
bool CanAddEnchantment(int a_EnchantmentID) const
Returns true if the given enchantment could be legally added to this object.
void Add(const cEnchantments &a_Other)
Adds the enchantments contained in a_Other into this object.
void Clear(void)
Removes all enchantments.
eEnchantment
Individual enchantment IDs, corresponding to their NBT IDs: https://minecraft.wiki/w/Data_values#Ench...
@ enchProjectileProtection
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 ...
size_t Count(void) const
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.
static unsigned int GetLevelCap(int a_EnchantmentID)
Get the maximum level the enchantment can have.
static int StringToEnchantmentID(const AString &a_EnchantmentName)
Converts enchantment name or ID (number in string) to the numeric representation; returns -1 if encha...
static cEnchantments SelectEnchantmentFromVector(const cWeightedEnchantments &a_Enchantments, int a_Seed)
Selects one enchantment from a Vector using cNoise.
unsigned int GetLevel(int a_EnchantmentID) const
Returns the level for the specified enchantment; 0 if not stored.
static void RemoveEnchantmentWeightFromVector(cWeightedEnchantments &a_Enchantments, int a_EnchantmentID)
Remove the entire enchantment (with weight) from the vector.
void AddFromString(const AString &a_StringSpec)
Adds enchantments in the stringspec; if a specified enchantment already exists, overwrites it.
AString ToString(void) const
Serializes all the enchantments into a string.
bool operator!=(const cEnchantments &a_Other) const
Returns true if a_Other doesn't contain exactly the same enchantments and levels.
cMap::const_iterator end() const
static cEnchantments GetRandomEnchantmentFromVector(const cWeightedEnchantments &a_Enchantments, MTRand &a_Random)
Gets random enchantment from Vector and returns it, with randomness derived from the provided PRNG.
cMap::const_iterator begin() const
Make this class iterable.
static int GetXPCostMultiplier(int a_EnchantmentID, bool FromBook)
Get the XP cost multiplier for the enchantment (for anvils).
static void CheckEnchantmentConflictsFromVector(cWeightedEnchantments &a_Enchantments, const cEnchantments &a_FirstEnchantment)
Check enchantment conflicts from enchantments from the vector.
static void AddItemEnchantmentWeights(cWeightedEnchantments &a_Enchantments, short a_ItemType, unsigned a_EnchantmentLevel)
Add enchantment weights from item to the vector.
cEnchantments(void)
Creates an empty enchantments container.
bool operator==(const cEnchantments &a_Other) const
Returns true if a_Other contains exactly the same enchantments and levels.
bool IsEmpty(void) const
Returns true if there are no enchantments.
std::map< int, unsigned int > cMap
Maps enchantment ID -> enchantment level.
cEnchantments m_Enchantments
Class to wrap any random engine to provide a more convenient interface.
Parses and contains the parsed data Also implements data accessor functions for tree traversal and va...