I am making a minecraft multiplayer server, and I am trying to make a safe, grief-proof spawnpoint. For that I need a few things:

  • Block Place and Destroy Protection (disable placing and breaking
    blocks in the spawn area)

  • Automatically set a player's spawnpoint upon joining, or if their spawnpoint is destroyed

  • Teleport them to the spawn upon respawning, if their spawn had to be reset

I have some command block code, but it only works for one player.

/execute run data get entity @p SpawnX
/spawnpoint @p 39 257 -16    
/tp @p 39 257 -16

I have attached my command block configuration and commands, in matching order.

My first command block is Repeating, Unconditional, Always Active

My second command block is Impulse, Unconditional, Needs Redstone

My third command block is Chain, Condition, Always Active

The way it currently works is by checking the x-coordinate of the player spawnpoint. The output is then inverted such that the next command block is triggered only if the player does not have an x-coordinate. If this is the case, that command block will set the player spawn, and the final command block teleports them.

my configuration

My question, is how do I make this work for all players? Using execute data get entity @a SpawnX does not work. @p only targets players nearest to the command block, which is 250 blocks in the sky. I need to be able to run this little command block script on every player in a loop, so upon joining and dying, the circuit works.


2 Answers 2


So from your question, I understood that you only wanted help with the spawn point problems and that the player will only get teleported and have their spawn point reset upon joining your server and then upon death if their spawn location was destroyed/obstructed.

I made it work with these 2 commands, first in a repeating command block and the second in a chain command block following the first:

execute as @a unless data entity @s SpawnX run tp 39 257 -16
execute as @a unless data entity @s SpawnX run spawnpoint @s 39 257 -16

The commands will execute as all players. The command will then not execute if a player has SpawnX data. Because the data gets reset when your bed gets destroyed or similar, we can easily test if the data of SpawnX exists.

So the command will only execute if a player has no value in their SpawnX data, and because they are in a command block chain the tp command will execute first so that we can still test for the nonexistent data for the spawn point command.

Command blocks:

<Repeating, Unconditional, Always Active> <Chain, Unconditional, Always Active>

The SpawnX will reset if a player's bed is destroyed or obstructed upon death. As well as when a Respawn Anchor doesn't have enough charges or is destroyed.

Would also recommend using the forceload command on the chunk that the command blocks will be present. This will make sure that the command blocks won't be unloaded when no players are near them.


Should be able to do something like this:

execute as @a[nbt=!{SpawnX}] run spawnpoint @s 39 257 -16

execute as @a[nbt=!{SpawnX}] run tp @s 39 257 -16

In two repeating command blocks. Not 100% certain if the NBT format is valid but it’s a start

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .