From 43fab8916bb71b829c13146b47998d0218295511 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 10 Dec 2024 23:10:36 +0100 Subject: [PATCH] Fix ##520 --- .../unicopia/mixin/MixinEnchantmentHelper.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinEnchantmentHelper.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinEnchantmentHelper.java index 0dd1aacf..82a96870 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinEnchantmentHelper.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinEnchantmentHelper.java @@ -8,12 +8,14 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.item.enchantment.SimpleEnchantment; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.EnchantmentLevelEntry; import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; @Mixin(EnchantmentHelper.class) abstract class MixinEnchantmentHelper { @@ -30,6 +32,8 @@ abstract class MixinEnchantmentHelper { @Inject(method = "getPossibleEntries", at = @At("RETURN")) private static void onGetPossibleEntries(int power, ItemStack stack, boolean treasureAllowed, CallbackInfoReturnable> info) { - info.getReturnValue().removeIf(entry -> !entry.enchantment.isAcceptableItem(stack)); + if (!stack.isOf(Items.BOOK)) { + info.getReturnValue().removeIf(entry -> entry.enchantment instanceof SimpleEnchantment && !entry.enchantment.isAcceptableItem(stack)); + } } }