Serialization for the new item attributes

This commit also cleans up the serialization code in other classes.
Fix Item.getAttribute for new attributes
Replace C-style casts with C++-style casts everywhere
Remove unnecessary if-statement
Add Lua function Item.hasAttribute