

export function onHitEntity(event) {
    const { attackingEntity, hadEffect, hitEntity, itemStack } = event;
    try {
        const playerPosition = attackingEntity.location;
        const hitEntityPosition = hitEntity.location;
        
        const directionX = hitEntityPosition.x - playerPosition.x;
        const directionZ = hitEntityPosition.z - playerPosition.z;

        const magnitude = Math.sqrt(directionX * directionX + directionZ * directionZ);

        const normalizedX = directionX / magnitude;
        const normalizedZ = directionZ / magnitude;

        hitEntity.applyKnockback(normalizedX, normalizedZ, 4, 0.3);
        hitEntity.applyDamage(4);

    } catch (error) {}
}


const knockback_leg = {
    onHitEntity:onHitEntity,
}
export default knockback_leg;
