--- ../src-base/minecraft/net/minecraft/enchantment/EnchantmentHelper.java
+++ ../src-work/minecraft/net/minecraft/enchantment/EnchantmentHelper.java
@@ -308,7 +308,7 @@
     public static int func_77514_a(Random p_77514_0_, int p_77514_1_, int p_77514_2_, ItemStack p_77514_3_)
     {
         Item item = p_77514_3_.func_77973_b();
-        int k = item.func_77619_b();
+        int k = item.getItemEnchantability(p_77514_3_);
 
         if (k <= 0)
         {
@@ -361,7 +361,7 @@
     public static List func_77513_b(Random p_77513_0_, ItemStack p_77513_1_, int p_77513_2_)
     {
         Item item = p_77513_1_.func_77973_b();
-        int j = item.func_77619_b();
+        int j = item.getItemEnchantability(p_77513_1_);
 
         if (j <= 0)
         {
@@ -450,7 +450,8 @@
         {
             Enchantment enchantment = aenchantment[k];
 
-            if (enchantment != null && (enchantment.field_77351_y.func_77557_a(item) || flag))
+            if (enchantment == null) continue;
+            if (enchantment.canApplyAtEnchantingTable(p_77505_1_) || ((item == Items.field_151122_aG) && enchantment.isAllowedOnBooks()))
             {
                 for (int l = enchantment.func_77319_d(); l <= enchantment.func_77325_b(); ++l)
                 {
