2023-11-08 13:58:31 +01:00
|
|
|
package com.minelittlepony.unicopia.mixin;
|
|
|
|
|
|
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
|
|
import org.spongepowered.asm.mixin.injection.Inject;
|
|
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
|
|
|
|
|
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
|
|
|
|
|
|
|
import net.minecraft.enchantment.Enchantment;
|
|
|
|
import net.minecraft.enchantment.EnchantmentHelper;
|
|
|
|
import net.minecraft.entity.LivingEntity;
|
|
|
|
|
|
|
|
@Mixin(EnchantmentHelper.class)
|
|
|
|
abstract class MixinEnchantmentHelper {
|
|
|
|
@Inject(method = "getEquipmentLevel", at = @At("RETURN"), cancellable = true)
|
|
|
|
private static void getEquipmentLevel(Enchantment enchantment, LivingEntity entity, CallbackInfoReturnable<Integer> info) {
|
|
|
|
Pony.of(entity).ifPresent(pony -> {
|
2023-11-09 16:08:07 +01:00
|
|
|
int initial = info.getReturnValue();
|
|
|
|
int implicitLevel = pony.getImplicitEnchantmentLevel(enchantment, initial);
|
|
|
|
if (implicitLevel != initial) {
|
|
|
|
info.setReturnValue(implicitLevel);
|
2023-11-08 13:58:31 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|