Is there a way to find a player at a specific Y position? I tried the command:

kill @a[y=177]

but this obviously didn't work since it just searches for a player starting the search at Y 177. Could I accomplish something that returns all players at a Y level? (I assume the command would be the same for X and Z, and to keep the post as covering as possible I have put all in the title, hence why the -OR- is written like that.)

  • Is it critical that it is an infinite plane on the Y level you select? The way to do this in Java Edition requires NBT access, so maybe you could consider using dx, dy, and dz to select a rectangular box in the Y level? – ExpertCoder14 Nov 9 '20 at 3:34
  • @ExpertCoder14 I’ve looked into those selectors and those look good, should I delete the question or leave it up, I don’t need it anymore, – Penguin Nov 9 '20 at 5:33
  • Hi Penguin, I've rolled back your edit because it changed the question entirely to something different. If you decide to use an alternative method to accomplish your task, your question should reflect that you used the old method, instead of pretending you always used your alternative method. Instead, state in your answer that "I found an alternative that works best", and state why that alternative is useful instead of what your old method is trying to do. – ExpertCoder14 Nov 10 '20 at 1:06
  • @ExpertCoder14 but the old method implied an infinite amount of points, while the new thing implies a finite area. It doesn't make sense for someone to be looking for everyone anywhere at a Y level to then see this answer, which only works for a finite amount of points. – Penguin Nov 10 '20 at 1:15
  • But you were originally looking for an infinite plane if possible, or at least thought that a way for an infinite plane existed, right? Moreover, that's what your original revision implies, and changing it to your proposed revision is like changing your question to something completely different. – ExpertCoder14 Nov 10 '20 at 1:19

x, y, z, dx, dy, and dz selectors can declare a box to find a player in.

Consider @a[x=5,y=24,z=-10,dx=5,dy=0,dz=4]
This defines a box starting at (5, 24, -10) and extending to (5+5, 24+0, -10+4) [which evaluates to] (10, 24, -6). Any player standing with their feet in these blocks will be selected. So, dy = 0 actually means that the box is one block high.

(u/TinyBreadBigMouth, Reddit Thread)

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.