I want to create two custom items. One with an aura that harms every player in the enemy team and one with an aura that heals every player in my team.

My problem here is, that I don't want to name the team in the item. Instead I want the item to detect if a player is a friend or an enemy.

/execute at Itemuser run effect give @a[distance=1..5] minecraft:regeneration 1 1

Can I type something like @a[is:friend,distance=1..5]?


The feature you want does not exist. You basically have two alternatives:

  1. Check each possible team manually. You probably created all of them yourself manually, so that effort should not be too extreme.
  2. Use one of the "same team/different team" distinguishing factors. Those are collision and friendly fire. You could for example summon an arrow, copy your UUID into it (much easier in 1.16) and put it above another player's head. If friendly fire is off (or you shortly disabled it for that check), they will only get damaged if they are on a different team. The problem is that that also damages them. This check does not work if the arrow has manually set damage:0.0. Other projectiles that don't deal damage also don't work. You could also use collision by teleporting one player close to another, checking if they get pushed and then teleporting both back, but that disrupts playing a lot, too.

I would recommend option #1.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.