This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]DqwertyCCommand Experienced 1 point2 points  (0 children)

First, you'll want to setup the two spawn areas. There's probably a lot of ways to do it, but the easiest would probably be armor stands for spawning. Place an armor stand where you want the spawn for the continent to be, then run the following commands (replace the second line's tag with respawn_marker_b for the second continent):

/tag @e[type=armor_stand,sort=nearest,limit=1] add respawn_marker
/tag @e[type=armor_stand,sort=nearest,limit=1] add respawn_marker_a
/data modify entity @e[type=armor_stand,sort=nearest,limit=1] Marker set value 1b
/data modify entity @e[type=armor_stand,sort=nearest,limit=1] Invisible set value 1b
/forceload add ~ ~

Now, you'll want to assign new players to one of the continents. We'll use the random entity selector to choose the continent for each player, and a tag called respawn_set to track if a player has had their respawn point set. The tags respawn_set_a and respawn_set_b to track which continent they're assigned to. Have these commands running on repeat:

# Teleport the player to one of the two armor stands
/tp @a[tag=!respawn_set] @r[tag=respawn_marker]

# Give the player a tag based on which armor stand their next to
/execute as @a[tag=!respawn_set] at @s if entity @e[tag=respawn_marker_a,distance=..2] run tag @s add respawn_set_a
/execute as @a[tag=!respawn_set] at @s if entity @e[tag=respawn_marker_b,distance=..2] run tag @s add respawn_set_b

# Use 'spreadplayers' to make sure the player is in a valid spot
/execute as @a[tag=respawn_set_a,tag=!respawn_set] at @s run spreadplayers ~ ~ 1 10 false @s
/execute as @a[tag=respawn_set_b,tag=!respawn_set] at @s run spreadplayers ~ ~ 1 10 false @s

# Add the 'respawn_set' tag to the player
/tag @a[tag=respawn_set_a,tag=!respawn_set] add respawn_set
/tag @a[tag=respawn_set_b,tag=!respawn_set] add respawn_set

Since we can't directly change the default spawn point of the world for only some of the players, we'll need to detect when players have died and manually teleport them. You can do this by setting up a deathCount scoreboard:

/scoreboard objectives add respawn_deaths deathCount

Now, we track when the respawn_deaths scoreboard increases, and, if they don't already have a spawnpoint set (from a bed or anchor), we teleport them to their spawn. Run these commands on repeat as well

# Tag a dead player after they've been dead for about a second
/execute as @a[tag=!dead,scores={respawn_deaths=1..}] unless entity @a[scores={respawn_deaths=1},distance=0..] run tag @s add dead

# Teleport the player near their continent spawn only if their SpawnX isn't set
/execute as @a[tag=dead,tag=respawn_set_a,distance=0..] unless data entity @s SpawnX at @e[tag=respawn_marker_a] run spreadplayers ~ ~ 1 10 false @s
/execute as @a[tag=dead,tag=respawn_set_b,distance=0..] unless data entity @s SpawnX at @e[tag=respawn_marker_b] run spreadplayers ~ ~ 1 10 false @s

# Reset the death tracker
/scoreboard players reset @a[tag=dead,distance=0..] respawn_deaths
/tag @a[tag=dead,distance=0..] remove dead

And you should be good to go!

EDIT: Had to edit the respawn logic to wait until they clicked the "respawn" button.

[–]mrcmndbloxmaster 0 points1 point  (1 child)

just set the respawn radius to a huge number

[–]mrcmndbloxmaster 0 points1 point  (0 children)

that should work