Mechanical energy is conserved as long as it is only acted upon by conservative forces, which means forces that are conserved in themselves I suppose, like a spring, or gravity, in that even when their is lost gravitational energy it can be regained. I hope that helps!