Skip to content

Commit

Permalink
Merge branch '1.20.1' into 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Sollace committed Dec 10, 2024
2 parents e0255c0 + 43fab89 commit a006373
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
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 {
Expand All @@ -30,6 +32,8 @@ private static void getEquipmentLevel(Enchantment enchantment, LivingEntity enti

@Inject(method = "getPossibleEntries", at = @At("RETURN"))
private static void onGetPossibleEntries(int power, ItemStack stack, boolean treasureAllowed, CallbackInfoReturnable<List<EnchantmentLevelEntry>> 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));
}
}
}

0 comments on commit a006373

Please sign in to comment.