0

In vanilla 1.8 using command blocks, is it possible to change a player's spawn point after they first join a server?

When a player first joins a server they are in location "A" When they press a button to leave the spawn point (or use any other trigger) they are sent to location "B" If they die after leaving the spawn they will respawn in location "B"

No mods or plugins 1.8 Vanilla McEdit map editing is OK

2
  • Is moving worldspawn an option, or do you use the spawn-chunks for keeping some farms running?
    – MrLemon
    Commented Jun 13, 2015 at 11:27
  • Moving the worldspawn each time is not an option, but moving it to build the Redstone and command blocks for the spawn thing should be fine. Basicly there is no set spawn point as of yet, and the map may be reset or changed completely before the server goes public.
    – Jonathan
    Commented Jun 14, 2015 at 2:29

2 Answers 2

0

Create a new scoreboard objective "new"

/scoreboard objectives add new dummy

Make the world spawn where you want the non-new players to spawn. Put a pressure plate under them (So they spawn on a pressure plate) that triggers a command block with the command

testfor @p[score_new_min=1,score_new=1] 

This will test for any player with a score of one in "new" Make that command block connect to a comparator that connects to another command block with the command

tp @p[score_new_min=1,score_new=1] x y z

Where x, y, and z are the coordinates of the place you want new players to spawn.

If you are going to have a lot of new players spawning at once however, this system might teleport the wrong new player. In that case, do this system except make the pressure plate in front of where they spawn, and make it their only option to walk over that pressure plate to get to the main spawn room.

2
  • This looks like it should work exactly how I need it to. One question though, if I were to replace the test for command from "@p" to "@a[r=3]" would it still work? I'll see about testing it, but I thought I'd ask, just in case you already have an answer.
    – Jonathan
    Commented Jun 14, 2015 at 2:24
  • Worldspawn spawns you somewhere in a 20 block radius (xz) around the coordinates you set it to (an on the highest block). You can't use a single pressure plate for this. Also, you never set the scoreboard objective to anything and the testfor is pointless.
    – MrLemon
    Commented Jun 14, 2015 at 8:47
1

This is one of the cases where using stat objectives on a scoreboard comes in handy, since it is impossible to detect players who don't have a score (i.e. a score of NULL, which is different from a score of 0!). stat objectives increase automatically depending on player actions, making them ideal for this. Set up a timePlayed objective like this:

/scoreboard objectives add timePlayed stat.playOneMinute

Contrary to the name, playOneMinute objectives increase at every game tick (making the value 1200 after one minute). You can use this objective to detect new players using @a[score_timePlayed=1].

To teleport new Players to a fixed point, set up a setblock clock and have it run

/tp @a[score_timePlayed=1] x y z

where x y z are the coordinates of your spawn.

Credit goes to /u/Boxfigs on reddit.


Should you want to re-declare an existing player as new (e.g. for testing), you can use

scoreboard players reset P timePlayed

where P is any valid target selector.

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.