Fix up enchantment at the enchanting table vs via a book. Adds in a method

that previously exists under a new name: canApplyAtEnchantingTable()
to determine enchantments that can apply at the enchanting table (a smaller
subset of all possible enchantments for an item, now). Also, add your
enchantments to the anvil book application list, if neccessary.
This commit is contained in:
Christian 2012-12-21 15:44:41 -05:00
parent ced432f31d
commit 51c19dd5f1
2 changed files with 41 additions and 1 deletions

View file

@ -0,0 +1,40 @@
--- ../src_base/minecraft/net/minecraft/enchantment/Enchantment.java
+++ ../src_work/minecraft/net/minecraft/enchantment/Enchantment.java
@@ -1,6 +1,9 @@
package net.minecraft.enchantment;
import java.util.ArrayList;
+
+import com.google.common.collect.ObjectArrays;
+
import net.minecraft.entity.EntityLiving;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
@@ -205,6 +208,27 @@
return this.type.canEnchantItem(par1ItemStack.getItem());
}
+ /**
+ * This applies specifically to applying at the enchanting table. The other method {@link #func_92037_a(ItemStack)}
+ * applies for <i>all possible</i> enchantments.
+ * @param stack
+ * @return
+ */
+ public boolean canApplyAtEnchantingTable(ItemStack stack)
+ {
+ return this.type.canEnchantItem(stack.getItem());
+ }
+
+ /**
+ * Add to the list of enchantments applicable by the anvil from a book
+ *
+ * @param enchantment
+ */
+ public static void addToBookList(Enchantment enchantment)
+ {
+ ObjectArrays.concat(field_92038_c, enchantment);
+ }
+
static
{
ArrayList var0 = new ArrayList();

View file

@ -5,7 +5,7 @@
Enchantment var8 = var5[var7];
- if (var8 != null && (var8.type.canEnchantItem(var2) || var4))
+ if (var8 != null && (var8.func_92037_a(par1ItemStack) || var4))
+ if (var8 != null && (var8.canApplyAtEnchantingTable(par1ItemStack) || var4))
{
for (int var9 = var8.getMinLevel(); var9 <= var8.getMaxLevel(); ++var9)
{