I am making this command block mini-game which requires two players to "interact" with each other. With interacting, I mean: two players meet each other, initiate the interaction, then command blocks compare a certain score of both players. If the score of player 1 is higher than player 2, then a command is executed at player 2 and vice versa. If the scores are equal, then a command is executed at both the players.

I know how to compare scores and how to use these to initiate commands, but I get stuck on the initiation of the interaction. I need a reliable way to initiate interaction between two players.

The first thing I tried was letting player 1 slap player 2 and then detect this by keeping a score for damage dealt and damaged taken. Then I can find an interaction by checking these scores. This is not reliable though, because:

  • If two interactions take place at the same time, the scoreboard doesn't show which player got slapped by which player and it might compare the wrong players. I thought to fix this by checking for the closest player that got slapped, but if another player stands closer than the player that I slapped, then the game picks the wrong pair.
  • The scoreboard doesn't differentiate between damage types. If somebody happens to fall next to me at the moment I try to slap somebody else, the game will choose the wrong player to interact with.

I thought I could just check for two players that are close together, but I cannot check for a distance between players lower than 1, which makes this method counter-intuitive, since you might interact with somebody by accident.

Perhaps I should check if a player holds a certain item and then perform the check that I described in the previous paragraph, but it's very easy to just leave the item in your hand and then the counter-intuitivity kicks in again.

I want to avoid long distance interactions, like shooting somebody with a bow or something.
Basically I want interaction similar to trading with a villager. You click on a player and then the interaction with that specific player takes place.
Note that the method must be easy expandable and should theoretically work for an infinite amount of interactions at the same time. This mini-game is played with potentially a lot of players at once, who can all have interactions with each other.

How can I make a reliable and intuitive player-player interaction with command blocks?


A player might not want to have interaction and will therefore try to flee. The commands should take that into consideration. Thanks @Fabian to point this out.

  • 3
    1. Upvote, because you really care about the quality of your command creation. 2. Would it work to let one player throw an item to another player? 3. If not: Would it work to let the players kill each other as a signal? :D 4. In theory you could test for distances lower than 1: Summon four armor stands at player, teleport each 0.5 blocks in a different direction, test if the other player is in a radius of 1 from all of them. Result: 0.5 radius test. Not perfectly circular, but very close. (You can add more armor stands and do sine calculation if you want it more circular.) But you would have Commented Sep 1, 2017 at 15:25
  • to do it on a special trigger, every tick would create too much lag. (Well, except if... Ok, I'll stop now and let you answer first.) Commented Sep 1, 2017 at 15:25
  • @Fabian Throwing an item at the other player could work, however, the other player might try to avoid interaction and run away, which would make it tricky to perform interaction. Killing the other player is certainly not an option, because that is what the commands are going to do depending on the score. The lowest score gets killed. If the scores are equal, both players are killed. The armor stand trick is very interesting, but if it needs a trigger, then I might also get away with just a 1 radius check. What would be the trigger though?
    – D-Inventor
    Commented Sep 1, 2017 at 15:35
  • You didn't say that one of the players doesn't want to interact. That changes it. But still: If the attacking player can aim well, you could set the pickup delay to 0, then the item gets picked up immediately. Otherwise you could for example let the players throw snowballs and kill all snowballs with a certain age (to reduce the range). Commented Sep 1, 2017 at 17:28
  • @Fabian I edited my question to include this significant detail. According to the internet, it is not possible to check if a player gets hit by a snowball, so although it would be the perfect solution, it doesn't work unfortunately. I could use the throwing of a snowball as a trigger to perform a radius check around the throwing player.
    – D-Inventor
    Commented Sep 1, 2017 at 17:59

2 Answers 2


here's my current thought on how to do something like this:

first limitations: the people can't really be in a huge group, will need some distance between them

also snowballs.

here's my thought: every player has their own unique number, they all will need a snowball to "interact" with another player, or throw the snowball at the other player.

when a player throws the snowball (the use stat of snowballs goes up one), you take the closes snowball that doesn't have a number, apply it the players number, and attach an witherskull (/entitydata on the passengers tag) and also give it the number. when the snowball dies (hits someone) use the witherskull to chose the nearest player (@p[c=1,r=1] or something).

now you have the player that threw the snowball (player a), and the player with the witherskull near them (player b). after doing the test/interaction kill the witherskull.

hopefully you can follow that. now I'll see if I can get something to work. if I do I'll update my answer.

  • This is a very interesting theory, and I can see this working in my game! If you can provide some commands for this, then I will accept this answer, but for now: +1
    – D-Inventor
    Commented Jan 6, 2018 at 8:17

Try making it so instead of measuring the damage dealt with the slap idea, make it measure knock back so that when they slap the player, they fall into a field of invisible particles and that activates the command blocks. if they try to flee, the particles never appear and therefore never sets off the reaction. to do it you would have to make a timer so when they walk up to each other they actually have time to flee but this might not work if they get slapped too early or flee too late.

  • Could you provide an example of this? If I understand it correctly, you say that I need to execute a command on the particles, but as far as I know, particles can not be targeted using target selectors. You speak about invisible particles. Are those summoned using commands? or are they a result of the knockback when hitting someone?
    – D-Inventor
    Commented Oct 10, 2017 at 9:43
  • you use the /particle command I think and make the amount at 1 and then the particles should be invisible so the players activate the particles by moving into them which uses chain command blocks to activate the next command which is whatever the scoreboard is and then you do whatever you want to next @D-Inventor
    – SirDude611
    Commented Oct 12, 2017 at 7:18
  • Could you provide example commands with your answer? Because I find it difficult to understand what you mean by: "the players activate the particles by moving into them..."
    – D-Inventor
    Commented Oct 12, 2017 at 14:51
  • when the play walks into the particle zone, or falls or whatever, the command block should make the next one activate, as the chain command blocks do. If you want an example, download the map "15 droppers" and break out of the map and find the command blocks. EDIT: They won't be invisible, but whatever
    – SirDude611
    Commented Oct 13, 2017 at 5:07
  • I haven't been able to check out that map, but after some research I stumbled upon the area of effect entity, which is an entity that applies an effect on any entity that it intersects with. I think that thát is what you referred to, because it's basically a bunch of particles. This is actually really interesting and I am going to have a look at it.
    – D-Inventor
    Commented Oct 13, 2017 at 19:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .