My problem is that I want to give every player on the same height as an area_effect_cloud within a radius of 25 blocks a scoreboard called 'stunned'.

The command for that would look something like this:

/execute @e[type=area_effect_cloud] ~ ~ ~ /scoreboard players set @a[y=~,r=25] stunned 1

But the only problem is that the y=~ is not a thing in Minecraft, does anyone have a solution to this, that isn't 1 or more command block for every height?

  • This probably becomes easier in 1.13 with the new execute functionality, but it should be possible in 1.12.
    – MBraedley
    Dec 17 '17 at 17:36

You almost had it, you just have to make a huge, flat box that takes the y coordinate of the entity, but ignores x and z. Like this:

/execute at @e[type=area_effect_cloud] run scoreboard players set @a[x=-30000000,z=-30000000,dx=60000000,dz=60000000,dy=1] stunned 1

Notice that I use values for dx, dy and dz, but only offset x and z, not y, that way the game takes the y coordinate of the entity.

If you have a fixed y coordinate, you can also use this for a tiny bit of less lag:

/execute positioned <coordinates> run scoreboard players set @a[x=-30000000,z=-30000000,dx=60000000,dz=60000000,dy=1] stunned 1

And if "stunned" is only ever 1 or 0, you can use tags (archive) instead.


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.