--- ../src_base/minecraft/net/minecraft/enchantment/EnchantmentHelper.java
+++ ../src_work/minecraft/net/minecraft/enchantment/EnchantmentHelper.java
@@ -463,7 +463,8 @@
         {
             Enchantment enchantment = aenchantment[k];
 
-            if (enchantment != null && (enchantment.type.canEnchantItem(item) || flag))
+            flag = (par1ItemStack.itemID == Item.book.itemID) && enchantment.isAllowedOnBooks();
+            if (enchantment != null && (enchantment.canApplyAtEnchantingTable(par1ItemStack) || flag))
             {
                 for (int l = enchantment.getMinLevel(); l <= enchantment.getMaxLevel(); ++l)
                 {

--- ../src_base/minecraft/net/minecraft/enchantment/EnchantmentHelper.java
+++ ../src_work/minecraft/net/minecraft/enchantment/EnchantmentHelper.java
@@ -463,7 +463,10 @@
         {
             Enchantment enchantment = aenchantment[k];
 
-            if (enchantment != null && (enchantment.type.canEnchantItem(item) || flag))
+            if (enchantment == null) continue;
+
+            flag = (par1ItemStack.itemID == Item.book.itemID) && enchantment.isAllowedOnBooks();
+            if (enchantment.canApplyAtEnchantingTable(par1ItemStack) || flag)
             {
                 for (int l = enchantment.getMinLevel(); l <= enchantment.getMaxLevel(); ++l)
                 {

Fix NPE in enchangint books.
Fix NPE in enchangint books.
