People will be protected from landslips, with more than £34m being invested to improve safety at coal tip sites across Wales.