So, let's say I have an area (defined by x, z) from 0, 0 to 5, 5 and another area from 7, 0 to 12, 5.

I now want to check if there are more chicken, sheeps, ect. in area 1 than on area 2 and tell this the player. Is there a way to achieve that?

(If this isn't possible it would be also okay to just print out the count of area 1 and area 2.)

  • @dan14941 Oh yes, if it differs from the answers already there! :)
    – Joschua
    Sep 9, 2014 at 13:04

3 Answers 3


As ModDL points out, the testfor command is what you can use. With a comparator, you can count up to 15 entities in one area, and differentiate by type if needed.

/testfor @e[type=cow,x=0,y=64,z=0,dx=5,dy=2,dz=5]

Outputs a signal strength of one for every cow that is in area 1. You can use redstone circuits to process this information, for example by using comparators to actually compare signals for once :)

Direct Display

Another option is to set the command blocks CommandStats:SuccessCountObjective and display that value on a scoreboard. To do so, use the following commands

/scoreboard objectives add Cows1 dummy Cows in Area 1
/blockdata x y z {CommandStats:{SuccessCountObjective:"Cows1"}}
/scoreboard objectives setdisplay sidebar Cows1

x,y,z are the coordinates of the command block. I have just found out about the existence of SuccessCountObjective, and haven't been able to test it yet. Also, the first line might not actually be needed.

Note that once you can access the success count as an objective, you can use it in JSON-formatted text as well, like signs or /tellraw.

  • Well you're missing the /stats command, but this is what I went with.
    – Joschua
    Sep 14, 2014 at 19:13
  • 1
    Could you post what commands you used to display how many mobs that were in an area? Jun 23, 2015 at 10:10

Use a /testfor command block for each area and each type of mob. Using comparators, you can detect the amount of mobs in the area in the form of redstone strength (upto 15). you can then use more comparators to determine which output is stronger.


I don't think it is possible with one command but what you can do is setup one command block for each block, and each command block tests for an entity then adds it to a scoreboard. This way obviously is not practical because it used allot of command blocks but if your areas are small it's doable.

You must log in to answer this question.

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