ForgePatch/patches/minecraft/net/minecraft/enchantment/Enchantment.java.patch

51 lines
2.0 KiB
Diff

--- ../src-base/minecraft/net/minecraft/enchantment/Enchantment.java
+++ ../src-work/minecraft/net/minecraft/enchantment/Enchantment.java
@@ -13,9 +13,9 @@
import net.minecraft.util.registry.RegistryNamespaced;
import net.minecraft.util.text.translation.I18n;
-public abstract class Enchantment
+public abstract class Enchantment extends net.minecraftforge.fml.common.registry.IForgeRegistryEntry.Impl<Enchantment>
{
- public static final RegistryNamespaced<ResourceLocation, Enchantment> field_185264_b = new RegistryNamespaced();
+ public static final RegistryNamespaced<ResourceLocation, Enchantment> field_185264_b = net.minecraftforge.fml.common.registry.GameData.getEnchantmentRegistry();
private final EntityEquipmentSlot[] field_185263_a;
private final Enchantment.Rarity field_77333_a;
public EnumEnchantmentType field_77351_y;
@@ -122,7 +122,7 @@
public boolean func_92089_a(ItemStack p_92089_1_)
{
- return this.field_77351_y.func_77557_a(p_92089_1_.func_77973_b());
+ return canApplyAtEnchantingTable(p_92089_1_);
}
public void func_151368_a(EntityLivingBase p_151368_1_, Entity p_151368_2_, int p_151368_3_)
@@ -138,6 +138,26 @@
return false;
}
+ /**
+ * This applies specifically to applying at the enchanting table. The other method {@link #canApply(ItemStack)}
+ * applies for <i>all possible</i> enchantments.
+ * @param stack
+ * @return
+ */
+ public boolean canApplyAtEnchantingTable(ItemStack stack)
+ {
+ return this.field_77351_y.func_77557_a(stack.func_77973_b());
+ }
+
+ /**
+ * Is this enchantment allowed to be enchanted on books via Enchantment Table
+ * @return false to disable the vanilla feature
+ */
+ public boolean isAllowedOnBooks()
+ {
+ return true;
+ }
+
public static void func_185257_f()
{
EntityEquipmentSlot[] aentityequipmentslot = new EntityEquipmentSlot[] {EntityEquipmentSlot.HEAD, EntityEquipmentSlot.CHEST, EntityEquipmentSlot.LEGS, EntityEquipmentSlot.FEET};