package com.xfestudio.mydimensionlord.platform;

import com.xfestudio.mydimensionlord.equipment.EquipmentRules;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;

public final class EquipmentCombat {
    private EquipmentCombat() {}
    public static boolean cooling(Player player, ItemStack stack) { return player.getCooldowns().isOnCooldown(stack.getItem()); }
    public static boolean hurt(Player player, LivingEntity target, float damage) { return target.hurt(player.damageSources().playerAttack(player), damage); }
    public static void spend(Player player, ItemStack stack, InteractionHand hand) {
        player.getCooldowns().addCooldown(stack.getItem(), EquipmentRules.SLASH_COOLDOWN);
        stack.hurtAndBreak(EquipmentRules.SLASH_DURABILITY_COST, player, broken -> broken.broadcastBreakEvent(hand));
    }
}
