Vanilla/Vanilla — pull request #565 by stewbasic (2013-02-05 18:56:55+00:00)
Title: Added enchantment mechanics on enchantment table

*Added methods to api/enchantment/Enchantment.java to generate and add random enchantments
*Logic based on Minecraft 1.4.7 source
*Changed "enchantment level" to "power level" in places to distinguish between the power level of an enchantment (I, II, III, IV, V) and the enchantment level displayed in the enchantment interface (1 to 30)
*Fixed bug in Enchantments.values(), which was assuming the enchantment ids were consecutive
*Fixed bug in Enchantment.addEnchantment etc, which weren't putting the NBT data in the correct format (http://www.minecraftwiki.net/wiki/Player.dat_Format#Item_structure)
*Fixed bug in ToolEnchantment.canEnchant (returned true on bows and swords)
*Simplified xp code
*Update EnchantmentTable's level display when it changes, rather than every tick
*Allow bookshelves on one side of table to contribute despite blocks on the other side (still not quite identical to Vanilla)
*Moved enchantment levels from EnchantmentTableInventory to EnchantmentTableWindow
*Fixed bug in Window.handleClick, event should be cancelled if the slot cannot be set
*Added tests EnchantmentTest and LevelComponentTest
Signed-off-by: stewbasic