I am making a data pack for a small game and creating a function.

game mode starts upon function activation.

At the start of the activation, I want the world spawn to be on the person starting the game and also the world border to be centered at the same location. Hence you can start the game in different parts of the same world.

I tried a few things but I am learning. I tried ~ and @s not sure of other options.

1 Answer 1


What you need to know to solve your problem is Context, just like you mentioned in your question. You can use @s to refer to an entity previously mentioned or ~ and ^ for relative positional arguments. You can set the context:

  • Using execute as <entity> for Entity Context

  • Using execute at <entity> for Positional Context

  • Trough actual context. For example, if a player types in their chat, the context passed for both entity and positional are theirs. Or if you run it trough a command block, you will get the block's position.

So, to explicitly answer your question, is to create a function with both commands:

worldborder center ~ ~
setworldspawn ~ ~ ~

And run that function as the player using execute, like this:

execute at <your player> run function <the function>

Ps: I called it context, but I'm not sure of the official name.

You must log in to answer this question.

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