mojira.dev
MC-169660

/teleport without <targets> can change the entity's rotation

The Bug

/teleport commands without <targets> argument specified can change the executor's rotation in certain command context.

To Reproduce

  • /execute rotated 0 0 run tp @s ~ ~ ~

    ✔ You are not moved at all.

  • /execute rotated 0 0 run tp @s ~ ~ ~ ~ ~

    ✔ Your rotation is changed. This is definitely intended because /teleport command should resolve relative pos arguments by the current command context.

  • /execute rotated 0 0 run tp ~ ~ ~

    ❌ Your rotation is changed.

Expected

Your rotation should not change because you didn't specify anything about your rotation in the /teleport command.

Code Analysis

yarn's mappings, 1.15.1, sorry.

When registering the /teleport <location: pos> command, there's a default argument DefaultPosArgument.zero() for the <rotation> argument, which makes

/teleport ~ ~ ~

equivalent to

/teleport @s ~ ~ ~ ~ ~

I suggest you replace it with null.

Thanks for t1546542 telling me this bug. I'm not sure whether this was reported before though, I couldn't find anything.

Comments 1

Can confirm in release 1.16.4

SPGoding

(Unassigned)

Confirmed

Platform

Normal

Commands

/teleport, /tp

1.15.1, 1.15.2 Pre-Release 1, 1.15.2, 20w06a, 20w07a, ..., 1.16.4, 20w45a, 21w03a, 1.17 Pre-release 2, 1.17.1

24w38a

Retrieved