Entity attack favouring

So I have an interaction entity surrounding the player so it can detect hit interactions and right clicks, but sometimes when I hit the interaction but there is an mob there too, it will hit the mob and not the interaction, even if it's behind the interaction. How can I fix this? I did try using teams to disable friendly fire, but this isn't ideal because I want mobs to still attack the player
Continue to help post