I've lived in the hood so I can speak from some experience...
The reason why some of these hoods don't go out of their way to attack white people that happen to live in or pass by these neighborhoods for whatever reason is that they fear police retaliation

, not the average white person walking down the street but the police themselves and what they'll do, that's all it comes down, to be honest.
Police don't care about Black people so attacking Black folks ain't draw much urgency from the police or the city, except chalk it up as another casualty/body. Sure, they'll be there, lackadaisically at the crime scene with little urgency, doing their little walk around or whatever, arrest whoever they can, and drive off afterward.
The police will be there in a hurry if a white man or white woman happens to get mugged, robbed, beaten, or killed, etc in a Black neighborhood. The city and police will make their presence felt to the point where the gangs, especially the ones involved in drug activity, it's bad for their business.
It's similar to how cartels in Mexico, Columbia, etc, have for the most part kill their people, in the crossfire and their local law enforcement and government officials don't do much about it outside of the usual but the moment an American gets killed by them you best believe authorities start getting engaged in the matter which is why cartels try their “best” nowadays not to kill American peoples as it draws unwanted attention to them and their operations.