This has got me. I need a command that tells me if all players on a server are in a radius of a command block. If one of them isn't in the radius, the command will be false. Any ideas? Thanks!

2 Answers 2


Use a command block with the command /testfor @a[rm=RADIUS]. point a comparator from the command block into another block, and on that block, place a redstone torch. This tests if anyone is outside of the radius, and inverts the signal, providing the output you want.

  • I don't like mixing command blocks with redstone, and neither should you. I'm sure there's a better way.
    – MBraedley
    Apr 1, 2016 at 11:20
  • What's the problem with mixing those ?.. Command blocks without redstone wont work... Apr 1, 2016 at 13:28
  • @David'mArm'Ansermot Blocks updates are a major source of lag when it comes to command block mechanisms; the fewer block updates the better. As of 1.9, it's quite easy to avoid all block updates. Not to mention that relying on physical logic is almost never multiplayer-friendly, though in this case multiplayer-friendliness isn't barred.
    – Skylinerw
    Apr 1, 2016 at 16:39
  • @MBraedley most large projects require more than one chained command, and since there are no turing-complete equivalent conditional operators available in command blocks, redstone is necessary for projects like this
    – Valkyrie
    Apr 1, 2016 at 23:50
  • @Inori: No, you are quite wrong on that. If memory serves, all that's needed for Turing-completeness is NOT and AND, which is easily accomplished.
    – MBraedley
    Apr 2, 2016 at 3:17

A block-updateless method would be to use 1.9's new command blocks with the "conditional" setting, as well as using /testforblock to check the success of a command.

Image example:

Repeating > chain > conditional chain

  1. Look for players outside the area. This has been reduced to 1 player, as otherwise the command is processed equal to the number of players outside the area. All we need to know is if there's at least 1.

    /testfor @a[rm=10,c=1]
  2. Check the SuccessCount value of the Repeating command block. Replace the XYZ values with that of the Repeating command block. If the value was 0, that means no players were found.

    /testforblock X Y Z minecraft:repeating_command_block -1 {SuccessCount:0}
  3. Conditional. Command to run based on there being no players outside the area.

    /say No players outside the area.

To further reduce server strain, you can disable output tracking on the command blocks. Do so by clicking the "O" button in the interface so that it turns into an "X":

Command block interface

  • This is one of the very few instances where testfor is the right command for the job.
    – MBraedley
    Apr 3, 2016 at 3:04

You must log in to answer this question.

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