import { world, system, EquipmentSlot} from "@minecraft/server";
import * as utils from "../utils";
export async function onEntityHurt(event) {
    const source = event.damageSource.damagingEntity;
    const entity = event.hurtEntity;
    if (source?.typeId === "minecraft:player") {
        const equippable = source.getComponent('equippable');
        if (!equippable) return;
        const mainhand = equippable.getEquipment(EquipmentSlot.Mainhand);
        if (mainhand?.typeId === 'pu_sg:scifi_hammer') {
            if(entity.isValid()){
                utils.runEntityCommand(entity, "effect @s blindness 5 255");
                entity.dimension.spawnParticle("pu_sg:sci_fi_hammer_1", {x: source.location.x, y: source.location.y + 1, z: source.location.z});
                entity.dimension.spawnParticle("pu_sg:sci_fi_hammer_2", {x: entity.location.x, y: entity.location.y + 1, z: entity.location.z});
            }
        }
    }
}