package ru.dbotthepony.mc.otm.mixin;

import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
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 ru.dbotthepony.mc.otm.item.weapon.EnergySwordItem;

@Mixin(EnchantmentHelper.class)
public class EnchantmentHelperMixin {
	@Inject(
		method = "getSweepingDamageRatio(Lnet/minecraft/world/entity/LivingEntity;)F",
		at = @At("HEAD"),
		cancellable = true)
	private static void getSweepingDamageRatio(LivingEntity p_44822_, CallbackInfoReturnable<Float> info) {
		var result = EnergySwordItem.getSweepingDamageRatioHook(p_44822_);

		if (result != null) {
			info.setReturnValue(result);
		}
	}
}
