1

I would like to test if two players (actually, slimes, but it should work the same way) are on the same team. I have two teams, Nether and Ender, and I would like to see if a given slime is on the same team as the nearest player. Is there a way to do this?

  • This will definitely require an execute command, and probably a scoreboard objective, but it's hard for me to come up with an exact solution right now. – MBraedley Dec 25 '14 at 3:24
  • You'll need a scoreboard for this. – 54D Dec 25 '14 at 3:41
1

Give one of them a custom name:

entitydata @e[type=Slime] {CustomName:"Slime1"}

If you want, make the name invisible:

entitydata @e[name=Slime1,type=Slime,c=1] {CustomNameVisible:0}

You'll then need to create a clock with a bunch of commands in it, one for each team you're using. Each command follows this format:

execute @e[team=<team-name>,name=Slime1] ~ ~ ~ testfor @e[c=1,type=Slime,team=<team-name>]

How it works

The entitydata commands both use @e[c=1] to return the nearest entity. The c argument makes it target only one of the entity, and always goes for the closest one.

The execute one targets a slime named "Slime1" on a specific team and tells it to test for another slime on the same team. Since you can only have one team tested at a time, you need seperate commands for each team.

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.