Improved Control of Enchantment.canApplyTogether() in Mod Enchantments, allowing both enchantments to determine if they can apply together.

This commit is contained in:
Lex Manos 2014-12-07 05:20:50 -08:00
parent 309fe700cd
commit fd3f948e4c
3 changed files with 34 additions and 2 deletions

View file

@ -0,0 +1,11 @@
--- ../src-base/minecraft/net/minecraft/command/CommandEnchant.java
+++ ../src-work/minecraft/net/minecraft/command/CommandEnchant.java
@@ -95,7 +95,7 @@
{
Enchantment enchantment2 = Enchantment.func_180306_c(short1);
- if (!enchantment2.func_77326_a(enchantment1))
+ if (!enchantment2.func_77326_a(enchantment1) || !enchantment1.func_77326_a(enchantment2)) //Forge BugFix: Let Both enchantments veto being together
{
throw new CommandException("commands.enchant.cantCombine", new Object[] {enchantment1.func_77316_c(j), enchantment2.func_77316_c(nbttaglist.func_150305_b(k).func_74765_d("lvl"))});
}

View file

@ -18,7 +18,18 @@
if (j <= 0)
{
@@ -450,7 +450,8 @@
@@ -408,7 +408,9 @@
{
EnchantmentData enchantmentdata1 = (EnchantmentData)iterator1.next();
- if (enchantmentdata1.field_76302_b.func_77326_a(Enchantment.func_180306_c(integer.intValue())))
+ Enchantment e1 = enchantmentdata1.field_76302_b;
+ Enchantment e2 = Enchantment.func_180306_c(integer.intValue());
+ if (e1.func_77326_a(e2) && e2.func_77326_a(e1)) //Forge BugFix: Let Both enchantments veto being together
{
continue;
}
@@ -450,7 +452,8 @@
{
Enchantment enchantment = aenchantment[k];

View file

@ -26,7 +26,17 @@
flag7 = itemstack2.func_77973_b() == Items.field_151134_bR && Items.field_151134_bR.func_92110_g(itemstack2).func_74745_c() > 0;
int k;
int l;
@@ -322,6 +325,8 @@
@@ -271,7 +274,8 @@
{
int l1 = ((Integer)iterator.next()).intValue();
- if (l1 != l && !enchantment.func_77326_a(Enchantment.func_180306_c(l1)))
+ Enchantment e2 = Enchantment.func_180306_c(l1);
+ if (l1 != l && !(enchantment.func_77326_a(e2) && e2.func_77326_a(enchantment))) //Forge BugFix: Let Both enchantments veto being together
{
flag8 = false;
++i;
@@ -322,6 +326,8 @@
}
}