So basically what i am doing is executing at an entity but i want to execute at exactly two of the entities (if there are two entities it will execute the next command, and if there any other amount it won't)

The entity is a an empty bottle and it has a score of isB

This is the command

/execute @e[name=Marker2] ~ ~ ~ /execute @e[c=3,score_isB_min=1,score_isB=1] ~ ~ ~ /execute @e[score_isP_min=1] ~ ~ ~ /say hi

Unfotunately the command will execute with any amount of bottles

1 Answer 1


The c parameter is only maximum count and there in no minimum variant.

You will have to use multiple command blocks to count the number of targets and run commands if that number is reached. Since you're looking for an exact number, no more or less, you can rely on the SuccessCount tag of the command block.

Repeating>chain>conditional chain

  1. Get the number of required entities as the SuccessCount value. Since you want only 2, the number of times the command will be processed has been limited to 3 to reduce server lag. This way the SuccessCount value will either be 0-1 for 0-1 entities, 2 for the desired amount, or 3 for 3+ entities.

    /testfor @e[score_isB_min=1,score_isB=1,c=3]
  2. Check the SuccessCount value of the repeating command block. Change the coordinates as needed. If the value is 2, this /testforblock command will be successful.

    /testforblock ~1 ~ ~ minecraft:repeating_command_block -1 {SuccessCount:2}
  3. Conditional. If the /testforblock command was successful, this would be the command to run as a result, which would be your /execute command.

    /execute @e[name=Marker2] ~ ~ ~ /execute @e[score_isB_min=1,score_isB=1] ~ ~ ~ /execute @e[score_isP_min=1] ~ ~ ~ /say hi

You must log in to answer this question.

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