When we're around people and we observe their behavior, there is a part of our brains that responds *as if we're performing the behavior ourselves.* So if you observe people, say, drinking, there is a part of your brain that relates to that as if you were joining in.
You are experiencing it subjectively as if you are doing it, even though you might not be physically participating.
For someone who is trying to break a habit, that can be devastating, because the old habit is still grooved in.
I had to completely leave behind a set of "friends" at one point in my life. It wasn't easy but when we decide to stop partying we are really forging a whole new identity, and making that break has to be part of it.
Set rules for yourself and then use those rules to protect yourself. Don't say you'll try to stay away from people who are using -- say you WILL stay away from them, and mean it, and stick to it.
Pretend you are a child, and you are also that child's mother. Then let that child play, but also protect that child. You can find both aspects of the self if you look for them, it's not that hard, and is a very powerful thing if you do.
Another idea. Cravings for substances probably always have at least some physiological component. I am sure one reason I outgrew some of the things I used to do was that I became a whole foods person in the early eighties and over the next several years gradually addressed imbalances without even realizing it. And there's lots better information out there now than there was then. Search on Amazon for Charles Gant, Hyla Cass, or Joan Larson. You'll probably find other similar books when you do the search. Many of those practitioners use combinations of amino acid and vitamin & mineral supplementation to boost levels of particular neurotransmitters. You might find that it helps you address any cravings that would otherwise create problems for you.
And last but not least -- I know you know this -- double down on the forgiveness, honey, and quadruple down on the self-forgiveness. Forgive, forgive, forgive . . .