(java minecraft 1.17) tag snowball based on owner

minecraft-commandsminecraft-java-edition

I want to make a projectile "belong" to a team by adding a tag to it. the players throw snowballs that are supposed to only hurt the enemies. Is there anyway I can use the owner nbt data to extract what tag it should use (the tags are T1 for team 1 and T2 for team 2). I have tried detecting the player within a certain distance (doesnt work if distance is less than 2) but that causes it to belong to both teams if 2 people are too close together. Thanks for reading and have a nice day.

Best Answer

I figured it out! If I give the potential thrower a snowball like so: /give selector snowball{tags:["tag"]} then I can search it using @e[type=snowball,nbt={Item:{tag:{tags:["tag"]}}}]!