Execute at a certain amount of entities in 1.9
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
Best Answer
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.
Get the number of required entities as the
SuccessCountvalue. 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 theSuccessCountvalue 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]Check the
SuccessCountvalue of the repeating command block. Change the coordinates as needed. If the value is 2, this/testforblockcommand will be successful./testforblock ~1 ~ ~ minecraft:repeating_command_block -1 {SuccessCount:2}Conditional. If the
/testforblockcommand was successful, this would be the command to run as a result, which would be your/executecommand./execute @e[name=Marker2] ~ ~ ~ /execute @e[score_isB_min=1,score_isB=1] ~ ~ ~ /execute @e[score_isP_min=1] ~ ~ ~ /say hi
Pictures about "Execute at a certain amount of entities in 1.9"



How do you execute all entities in Minecraft?
The game processes these subcommands in order from front to end, for example, the following commands are different:How many entities can be in a block?
All living creatures in Minecraft are called entities, and there is a limit to how many of them can stay together in one place. This is a game rule called entity cramming that by default does not allow more than 24 mobs to stand on the same block.Counting Entities/Players in Minecraft 1.9-1.12
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Liza Summer, Olya Kobruseva, Karolina Grabowska, cottonbro

