Maybe the first step would be to think before you speak and think about how other people will react to what you say. If they would be taken aback by what you wanted to say, then don't say it.
I could give a rat's ass if you are a jerk to me. I'm not your friend, but it's obviously affecting your social life. If you want to have a social life and friends around you, then you need to work on it.