Here's why it doesn't work (openJK client)
CM_trace traceline function doesn't check for entities (by the way the reason why there are no shadows drawn when you are standing on ents is exactly the same)
i think if you replaced it for a trace line function that does, and append the switch...