K, so i'll be brief about this
I'm making a new datapack, i won't spoil what it is
But there is this little problem:
There is this command:
tp @s ^ ^2 ^10
Whenever the command is executed from the datapack's commands, it teleports the player to 24 0 56
Whenever the player executes it in game, it teleports them to the right place (Ten blocks in the direction you are facing)
Any ideas?
I'm making a new datapack, i won't spoil what it is
But there is this little problem:
There is this command:
tp @s ^ ^2 ^10
Whenever the command is executed from the datapack's commands, it teleports the player to 24 0 56
Whenever the player executes it in game, it teleports them to the right place (Ten blocks in the direction you are facing)
Any ideas?
2
This is because the command doesn't run at the right place. Adding "execute at @s" causes the command to run at the player.
execute at @s run tp ^ ^2 ^10Yeah, by default a data pack executes as the server entity at the world spawn.
For command blocks it's the server entity at the command block location.
To change the location of execution, use /execute at:
We can extend this to execute as the player, making @s refer to the nearest player:
For command blocks it's the server entity at the command block location.
To change the location of execution, use /execute at:
/execute at @p run tp @p ^x ^y ^z(Note that @s wouldn't work, because that selects the server entity, not the player)We can extend this to execute as the player, making @s refer to the nearest player:
/execute as @p at @s run tp @s ^x ^y ^zAnd finally, instead of selecting the nearest player, we can select all players matching a certain conditions, see target selector arguments./execute as @a[gamemode=survival] at @s run tp @s ^x ^y ^zNote that "@s" still refers to what's being targetted in the "as" instruction, which is "@a[gamemode=survival]" in the last command.
