<commit_before>--- ../src-base/minecraft/net/minecraft/enchantment/EnchantmentHelper.java
+++ ../src-work/minecraft/net/minecraft/enchantment/EnchantmentHelper.java
@@ -292,7 +292,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 i = item.func_77619_b();
+        int i = item.getItemEnchantability(p_77514_3_);
 
         if (i <= 0)
         {
@@ -339,7 +339,7 @@
     {
         List<EnchantmentData> list = Lists.<EnchantmentData>newArrayList();
         Item item = p_77513_1_.func_77973_b();
-        int i = item.func_77619_b();
+        int i = item.getItemEnchantability(p_77513_1_);
 
         if (i <= 0)
         {
@@ -380,7 +380,8 @@
 
         while (iterator.hasNext())
         {
-            if (!p_185282_1_.field_76302_b.func_77326_a(((EnchantmentData)iterator.next()).field_76302_b))
+            Enchantment e2 = iterator.next().field_76302_b;
+            if (!p_185282_1_.field_76302_b.func_77326_a(e2) || !e2.func_77326_a(p_185282_1_.field_76302_b)) //Forge BugFix: Let Both enchantments veto being together
             {
                 iterator.remove();
             }
@@ -395,7 +396,7 @@
 
         for (Enchantment enchantment : Enchantment.field_185264_b)
         {
-            if ((!enchantment.func_185261_e() || p_185291_2_) && (enchantment.field_77351_y.func_77557_a(item) || flag))
+            if ((!enchantment.func_185261_e() || p_185291_2_) && (enchantment.canApplyAtEnchantingTable(p_185291_1_) || (flag || enchantment.isAllowedOnBooks())))
             {
                 for (int i = enchantment.func_77325_b(); i > enchantment.func_77319_d() - 1; --i)
                 {<commit_msg>Fix a condition that caused the enchantment table to roll invalid enchantments.<commit_after>--- ../src-base/minecraft/net/minecraft/enchantment/EnchantmentHelper.java
+++ ../src-work/minecraft/net/minecraft/enchantment/EnchantmentHelper.java
@@ -292,7 +292,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 i = item.func_77619_b();
+        int i = item.getItemEnchantability(p_77514_3_);
 
         if (i <= 0)
         {
@@ -339,7 +339,7 @@
     {
         List<EnchantmentData> list = Lists.<EnchantmentData>newArrayList();
         Item item = p_77513_1_.func_77973_b();
-        int i = item.func_77619_b();
+        int i = item.getItemEnchantability(p_77513_1_);
 
         if (i <= 0)
         {
@@ -380,7 +380,8 @@
 
         while (iterator.hasNext())
         {
-            if (!p_185282_1_.field_76302_b.func_77326_a(((EnchantmentData)iterator.next()).field_76302_b))
+            Enchantment e2 = iterator.next().field_76302_b;
+            if (!p_185282_1_.field_76302_b.func_77326_a(e2) || !e2.func_77326_a(p_185282_1_.field_76302_b)) //Forge BugFix: Let Both enchantments veto being together
             {
                 iterator.remove();
             }
@@ -395,7 +396,7 @@
 
         for (Enchantment enchantment : Enchantment.field_185264_b)
         {
-            if ((!enchantment.func_185261_e() || p_185291_2_) && (enchantment.field_77351_y.func_77557_a(item) || flag))
+            if ((!enchantment.func_185261_e() || p_185291_2_) && (enchantment.canApplyAtEnchantingTable(p_185291_1_) || (flag && enchantment.isAllowedOnBooks())))
             {
                 for (int i = enchantment.func_77325_b(); i > enchantment.func_77319_d() - 1; --i)
                 {
{'fraction_non_alphanumeric': 0.1362876254180602, 'fraction_numerical': 0.12876254180602006, 'mean_word_length': 2.549950544015826, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4265871', 'n_tokens_mistral': 1576, 'n_tokens_neox': 1299, 'n_words': 193}