diff --git a/felt-enchanting-api/src/main/java/net/feltmc/feltapi/api/enchanting/BookEnchantableItem.java b/felt-enchanting-api/src/main/java/net/feltmc/feltapi/api/enchanting/BookEnchantableItem.java deleted file mode 100644 index 524edd8..0000000 --- a/felt-enchanting-api/src/main/java/net/feltmc/feltapi/api/enchanting/BookEnchantableItem.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.feltmc.feltapi.api.enchanting; - -import net.minecraft.world.item.ItemStack; - -public interface BookEnchantableItem { - /** - * Allow or forbid the specific book/item combination as an anvil enchant - * - * @param stack The item - * @param book The book - * @return if the enchantment is allowed - */ - default boolean isBookEnchantable(ItemStack stack, ItemStack book) - { - return true; - } -} diff --git a/felt-enchanting-api/src/main/java/net/feltmc/feltapi/api/enchanting/EnchantmentExtension.java b/felt-enchanting-api/src/main/java/net/feltmc/feltapi/api/enchanting/EnchantmentExtension.java new file mode 100644 index 0000000..578b0c2 --- /dev/null +++ b/felt-enchanting-api/src/main/java/net/feltmc/feltapi/api/enchanting/EnchantmentExtension.java @@ -0,0 +1,10 @@ +package net.feltmc.feltapi.api.enchanting; + +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.enchantment.Enchantment; + +public interface EnchantmentExtension { + default boolean canApplyAtEnchantingTable(ItemStack stack) { + return stack.getItem().canApplyAtEnchantingTable(stack, (Enchantment) this); + } +} diff --git a/felt-enchanting-api/src/main/java/net/feltmc/feltapi/mixin/enchanting/AnvilScreenHandlerMixin.java b/felt-enchanting-api/src/main/java/net/feltmc/feltapi/mixin/enchanting/AnvilScreenHandlerMixin.java index 33106c8..6c77999 100644 --- a/felt-enchanting-api/src/main/java/net/feltmc/feltapi/mixin/enchanting/AnvilScreenHandlerMixin.java +++ b/felt-enchanting-api/src/main/java/net/feltmc/feltapi/mixin/enchanting/AnvilScreenHandlerMixin.java @@ -1,7 +1,5 @@ package net.feltmc.feltapi.mixin.enchanting; -import net.feltmc.feltapi.api.enchanting.BookEnchantableItem; -import net.feltmc.feltapi.api.enchanting.EnchantingItem; import net.minecraft.world.inventory.AnvilMenu; import net.minecraft.world.item.EnchantedBookItem; import net.minecraft.world.item.ItemStack; diff --git a/felt-enchanting-api/src/main/java/net/feltmc/feltapi/mixin/enchanting/EnchantmentMixin.java b/felt-enchanting-api/src/main/java/net/feltmc/feltapi/mixin/enchanting/EnchantmentMixin.java index ddc904d..33c1abd 100644 --- a/felt-enchanting-api/src/main/java/net/feltmc/feltapi/mixin/enchanting/EnchantmentMixin.java +++ b/felt-enchanting-api/src/main/java/net/feltmc/feltapi/mixin/enchanting/EnchantmentMixin.java @@ -2,6 +2,7 @@ import net.feltmc.feltapi.api.enchanting.EnchantingItem; +import net.feltmc.feltapi.api.enchanting.EnchantmentExtension; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.enchantment.Enchantment; import org.spongepowered.asm.mixin.Mixin; @@ -10,9 +11,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Enchantment.class) -public class EnchantmentMixin { +public class EnchantmentMixin implements EnchantmentExtension { @Inject(method = "canEnchant", at = @At("HEAD"), cancellable = true) public void injectEnchantmentCheck(ItemStack stack, CallbackInfoReturnable callback){ - callback.setReturnValue(stack.getItem().canApplyAtEnchantingTable(stack, (Enchantment) (Object)this)); + callback.setReturnValue(this.canApplyAtEnchantingTable(stack)); } } diff --git a/felt-enchanting-api/src/main/resources/fabric.mod.json b/felt-enchanting-api/src/main/resources/fabric.mod.json index 712e2d2..b2ca6a1 100644 --- a/felt-enchanting-api/src/main/resources/fabric.mod.json +++ b/felt-enchanting-api/src/main/resources/fabric.mod.json @@ -31,6 +31,9 @@ "loom:injected_interfaces": { "net/minecraft/class_1792": [ "net/feltmc/feltapi/api/enchanting/EnchantingItem" + ], + "net/minecraft/class_1887": [ + "net/feltmc/feltapi/api/enchanting/EnchantmentExtension" ] } }