4

I'm new to Command Blocks in Minecraft and want to solve this problem:

If X players in radius Y around the command block, then output power.

I read a bit about testfor and tried things like testfor @p[r=5,c=2] which I hoped would only output power if there are at least 2 players in a radius of 5. Doesn't work. Then I only tried testfor @p[r=5] and added a comparator block at the end and hoped it would output as much power players are in the given radius. Doesn't work.

How can I actually test how many players are in a specific radius? How do I only output power if a given number of players is passed?

  • 1
    Just to make sure, you are supplying a pulse of redstone power to the command block, right? Command blocks don't just output willy-nilly. – MBraedley Aug 29 '13 at 13:48
  • 1
    Unless u r in a version above 1.9 – Chemical Comrade Dec 14 '16 at 8:11
5

@p targets the closest player so will only find 1 player each time, even if more are within the radius you have given.

@a targets all players with the arguments given, so should work for either of the methods you are trying.

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.