API
Functions and classes available in the Lua API
Public Types | Public Member Functions | Static Public Member Functions | List of all members
cEnchantments Class Reference

#include <0015.h>

Public Types

enum  {
  enchProtection = 0, enchFireProtection = 1, enchFeatherFalling = 2, enchBlastProtection = 3,
  enchProjectileProtection = 4, enchRespiration = 5, enchAquaAffinity = 6, enchThorns = 7,
  enchSharpness = 16, enchSmite = 17, enchBaneOfArthropods = 18, enchKnockback = 19,
  enchFireAspect = 20, enchLooting = 21, enchEfficiency = 32, enchSilkTouch = 33,
  enchUnbreaking = 34, enchFortune = 35, enchPower = 48, enchPunch = 49,
  enchFlame = 50, enchInfinity = 51
}
 Individual enchantment IDs, corresponding to their NBT IDs ( http://www.minecraftwiki.net/wiki/Data_Values#Enchantment_IDs ) More...

Public Member Functions

void AddFromString (const AString &a_StringSpec)
 Adds enchantments in the stringspec; if a specified enchantment already exists, overwrites it.
 cEnchantments (void)
 Creates an empty enchantments container.
 cEnchantments (const AString &a_StringSpec)
 Creates an enchantments container filled with enchantments parsed from stringspec.
void Clear (void)
 Removes all enchantments.
int GetLevel (int a_EnchantmentID) const
 Returns the level for the specified enchantment; 0 if not stored.
bool IsEmpty (void) const
 Returns true if there are no enchantments.
void SetLevel (int a_EnchantmentID, int a_Level)
 Sets the level for the specified enchantment, adding it if not stored before or removing it if level <= 0.
AString ToString (void) const
 Serializes all the enchantments into a string.

Static Public Member Functions

static int StringToEnchantmentID (const AString &a_EnchantmentName)
 Converts enchantment name to the numeric representation; returns -1 if enchantment name not found; case insensitive.

Detailed Description

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. 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 and will always use numeric IDs.

Member Enumeration Documentation

anonymous enum

Individual enchantment IDs, corresponding to their NBT IDs ( http://www.minecraftwiki.net/wiki/Data_Values#Enchantment_IDs )

Enumerator:
enchProtection 
enchFireProtection 
enchFeatherFalling 
enchBlastProtection 
enchProjectileProtection 
enchRespiration 
enchAquaAffinity 
enchThorns 
enchSharpness 
enchSmite 
enchBaneOfArthropods 
enchKnockback 
enchFireAspect 
enchLooting 
enchEfficiency 
enchSilkTouch 
enchUnbreaking 
enchFortune 
enchPower 
enchPunch 
enchFlame 
enchInfinity 

Constructor & Destructor Documentation

cEnchantments::cEnchantments ( void  )

Creates an empty enchantments container.

cEnchantments::cEnchantments ( const AString &  a_StringSpec)

Creates an enchantments container filled with enchantments parsed from stringspec.

Member Function Documentation

void cEnchantments::AddFromString ( const AString &  a_StringSpec)

Adds enchantments in the stringspec; if a specified enchantment already exists, overwrites it.

void cEnchantments::Clear ( void  )

Removes all enchantments.

int cEnchantments::GetLevel ( int  a_EnchantmentID) const

Returns the level for the specified enchantment; 0 if not stored.

bool cEnchantments::IsEmpty ( void  ) const

Returns true if there are no enchantments.

void cEnchantments::SetLevel ( int  a_EnchantmentID,
int  a_Level 
)

Sets the level for the specified enchantment, adding it if not stored before or removing it if level <= 0.

static int cEnchantments::StringToEnchantmentID ( const AString &  a_EnchantmentName)
static

Converts enchantment name to the numeric representation; returns -1 if enchantment name not found; case insensitive.

AString cEnchantments::ToString ( void  ) const

Serializes all the enchantments into a string.