mojira.dev
MC-121875

Can't move player position using /execute store result

The command "/execute store result" can be used to update a mob's position, but not that of a player.

After running the commands:

/scoreboard objectives add storedY dummy
/execute store result score @s storedY run data get entity @s Pos[1] 1.1

The following command does work:

/execute store result entity @e[type=creeper,limit=1,sort=nearest] Pos[1] double 1 run scoreboard players get @s storedY

But the following command does not:

/execute store result entity @s Pos[1] double 1 run scoreboard players get @s storedY

Linked issues

Comments 6

user-f2760

Player data is not editable, never has been.

Richard A. Hallett

Ah, that's a shame. I was hoping to use this in a data pack to teleport a player to somewhere a vast distance away, then later back to where they were. Chunk loading would mean that teleporting to an entity would be unlikely to work, and the teleport command doesn't accept scoreboard data as inputs. Position seems like perhaps the one thing that could be safe to be editable, given that the teleport command exists.

user-f2760

You can spawn in an entity, run a function on it, make it move to the desired location, make the player teleport to it (execute at @s run teleport player @s) and then kill the entity.

Richard A. Hallett

I'll have to try that. I had assumed that moving an entity to an unloaded chunk would mean it would instantly unload, so commands not work on it.

user-f2760

If the entity is moved in the function it is running, it can still be targeted.
So have a function file that the entity runs, that moves the entity, that teleports the player to the entity and that removes the entity.

Richard A. Hallett

I'll do that. Thanks for the help.

Richard A. Hallett

(Unassigned)

Unconfirmed

Minecraft 17w45b

Retrieved