3

For an upcoming parkour event in our server, I wanted to do a system with command blocks in which if a player falls to a certain Y coordinate (e.g y=134), they get teleported back to the spawn. I've looked around and I've seen similar questions asked, however I can not get the commands to work + I need to cover an entire area, not just a block.

The specific coordinates I need people to be teleported back to the spawn are from 999909 136 999955 to 999897 136 999825.

Version is 1.16.5 on Java. All help appreciated.

2

I recommend setting up a command block as repeat, unconditional and always active and entering a tp command.

The key to covering only a certain area is using the target selector arguments, particularly the volume dimension arguments. Something like

tp @a[x=<value>, dx=<value>, y=<value>, dy=<value>, z=<value>, dz=<value>] <location>

... where...

  • The @a target selector targets all players
  • The <x>,<y>,<z> and <dx>,<dy>,<dz> selector arguments limit the @a selection only to a certain volume
  • The <location> is the x, y, and z coordinates of where you want the players teleported to

... will select all players, whose hitbox is at least partially contained in the volume defined by the start point [x, y, z] and the difference [dx, dy, dz] from the start point. Hence

@a[x=0, dx=10, y=0, dy=10, z=0, dz=10]

... will target all players in a cubic volume between the points [0, 0, 0] and [10, 10, 10].

If you define only the difference, the selector will select everyone in the volume starting from the coordinates of the entity executing the command (can be your command block).

So, in other words, in your case something like this should work:

tp @a[x=999909, y=136, z=999955, dx=12, dy=0, dz=130] <target x> <target y> <target z>
3
  • I've placed the command block and entered everything correctly, but nothing is teleported. I just get "No entity was found" in the output – Maxolotl_ Apr 26 at 19:25
  • I fixed a mistake of mine in the command I accidentally made - but it shouldn't have made the command find no targets, only make the target area (absurdly) big. I recommend trying the command on a small scale, such as making a new "Redstone Ready" Superflat world (It's under Customize -> Presets), giving yourself a command block and setting up a command such as this tp @a[x=5, y=0, z=5, dx=10, dy=60, dz=10] 0 56 0 and see if you can create an area near the spawn that'd teleport you to the spawn upon entry. – Marty Cagas Apr 26 at 20:00
  • I set up the superflat, put down the command block, nowhere I went would teleport me. I'll just leave out the teleport system. It's weirdly complicated and I can't get it to work. Thank you for the help, though – Maxolotl_ Apr 26 at 21:21

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.