3

I own a server, and have built a large indoor structure at spawn. I would like new players to spawn inside this structure. Upon research, Minecraft automatically spawns all players at the highest available y position, meaning players will spawn on my roof instead of inside. I've tested this myself; used /setworldspawn in the center of the building, and used /kill on myself a bunch of times. About half the time I spawned on the roof, the other half outside my building.

I would like to target all players above y=69 in a 60 block radius and teleport them to x=-62,y=64,z=-245. I have a hopper clock and command block already set up with everything except the ability to target everyone on my roof:

What do I want to put in the command block to teleport anyone on my roof into the building?

1
  • 1
    A solid workaround I've found is to set the default gamemode to adventure, then run a clock at spawn to switch all adventure mode players over to survival. When the default gamemode is adventure, everyone spawns at the pinpoint exact spawn, which is exactly what I want. Plus, it's a bit more graceful than spawning on top of the building then teleporting inside a second or two later.
    – Gigazelle
    Commented Mar 3, 2015 at 7:19

2 Answers 2

1

Use the y and dy syntax for commands:

/tp @a[y=69,dy=255,r=60] 62 64 -245
5
  • Whats the problem with this command?
    – Moddl
    Commented Mar 3, 2015 at 0:32
  • 4
    Probably because just posting the command without any explanation typically makes for a poor answer.
    – user66184
    Commented Mar 3, 2015 at 2:20
  • What means "r=60" ? Why "dy=255" and not for example "dy=186", is it filtering the max height ? Why "y=69" does that mean everything above y=69 ?
    – Hybris95
    Commented Mar 3, 2015 at 10:07
  • The r is the range for the selection, the dy is the height of the selection. This will select all players that are in 60 block radius and are within a height range of 255 starting from 69. The 255 is just an arbitrary number i selected.
    – Moddl
    Commented Mar 4, 2015 at 0:30
  • 1.13 syntax: distance=..60
    – pppery
    Commented Aug 29, 2018 at 18:03
1

The classic, simple and efficient solution is to use a plugin like Essentials to define a precise spawn position. But you need to use bukkit spigot or some other modified server.

If you are on vanilla minecraft (no modification), a workaround is to put pressure plates on all potential spawn places (20x20 => [https://minecraft.wiki/w/Spawn#World_spawn][1]) which will activate command block(s).

Then you have 2 options:

  • The first is simply to teleport players to the position you want:

    tp <player> <x> <y> <z>

for example (if 123 456 789 is the world spawn point):

tp @a[x=123,y=456,z=789,r=11] 987 654 321

(r is the radius and if you want to keep a random on spawn point you can use relative coordinates (using "~").

  • The second solution is to use a fill clock:

(search it on google to know what it is and how to create one).

How to (re)start a fill clock:

setblock <x> <y> <z> air
setblock <x> <y> <z> redstone_block

As x,y,z put the coordinates of the first redstone_block of the fill clock.

What to put on the fill clock: tp @a[x=123,y=456,z=789,r=11] 987 654 321

If you want to be more precise on the area where players must be TP use a invisible ArmorStand with PersistenceRequired:1 to define at first point of the area and use "dx", "dy" and "dz" parameters in the selector to define the relative coordinates of the second point of your area. It will result in a command like this one:

execute @e[type=ArmorStand,name=MyAreaFirstPoint,c=1] ~ ~ ~ tp @a[dx=20,dy=3,dz=20] <x> <y> <z>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.