mojira.dev
MC-95971

Constant teleport while on ground incorrectly placing player slightly above ground

NOTE: Constant teleport with a command to testfor OnGround:1b running after it will always make the testfor output true, even if the player isn't actually on the ground. Place a repeat command running the teleport running into a chain command running testfor OnGround:1b and then put a comparator output to see that the command outputs true no matter where the player gets teleported. See MC-108209

Note: The same occurs with /teleport in 1.10

When a player is constantly teleported via command block, while they are not flying and on the ground and the coordinates they are being teleported are on ground, the camera will jitter a very small but noticeable amount. This is probably due to the teleport for some reason not placing the player completely on the ground. This can be seen by using a constant teleport while having slowness 6. When you try to move without teleporting, you can't due to the slowness, however when you are being teleported, you can move slightly, which hints that the teleport is placing the player slightly off the ground.

When relative coordinates are used, the player IS placed correctly on the ground, despite the coordinate shown being the same on the y axis as the exact number teleport.

To reproduce:

 

Test with relative coordinates:

1. Stand on a location without flying.
2. Place a repeat command block with /tp @p ~ ~ ~.
3. Notice that when you are standing on the ground correctly and there is no jittery camera.
4. Slowness 6 should prevent all player directional movement:

/effect @p slowness 1000 6

 

1.13: /effect give @p slowness 1000 6

5. Notice that when you move, you can't due to you being correctly placed on the ground, unlike using exact number coordinates in previous tests.

 

 

Test 2 with just teleport:

1. Stand on a location without flying.
2. Place a repeat command block that teleports you to your exact location where you are standing on the ground and set it to run. (NO RELATIVE COORDINATES! Something like /tp @p 9.123 25.0 23.1)
3. Notice camera slightly jittering.

Test 3 with slowness:

1. Stand on a location without flying.
2. Slowness 6 should prevent all player directional movement: /effect @p slowness 1000 6
3. Try to move, see that you cannot.
4. Place a repeat command block that teleports you to your exact location where you are standing on the ground and set it to run. (NO RELATIVE COORDINATES! Something like /tp @p 9.123 25.0 23.1)
5. Try to move, see that you slightly move towards where you are going, suggesting that you are not completely on the ground but very slightly above it.

Test 4 with OnGround (NO LONGER TESTABLE AS OF 16w39c - see MC-108209):

1. Stand on a location without flying.
2. Place a repeat command block that teleports you to your exact location where you are standing on the ground and set it to run. (NO RELATIVE COORDINATES! Something like /tp @p 9.123 25.0 23.1)
3. Place a repeat command block that runs

/testfor @p {OnGround:1b}

 

1.13: /execute if entity @p[nbt={OnGround:1b}]

and run the command with a comparator out of it

4. Notice that the comparator turns off when the teleport command is running and turns back on when the teleport command stops. This means that the player is not on the ground according to the game while the teleport is happening. See Marcono1234's comment below.


Code analysis by @unknown can be found in this comment.

Linked issues

Attachments

Comments 13

Unable to reproduce with

/tp @p ~ ~ ~

You need to use exact coordinates not relative.

Cannot confirm the first scenario, are moving while being teleported?
If only the y-coordinate is absolut you are sliding over the ground

What do you mean?

Do a repeat cmd with something like /tp @p 123 25.0 123 with x y z set to a location.

Make sure it is a coordinate that should place you on the ground.

Notice that the camera jitters up and down slightly.

The video attached shows the camera jitter in 1.9 pre-2.

3 more comments

Please link to this comment in the description of the report.

The following is based on decompiled version of Minecraft 1.8 using MCP. All method and class names are the names used in the decompiled version.

The reason might be that the client sends to the server that it is not on ground. The reason for this is that the public void moveEntity(double x, double y, double z) method of the net.minecraft.entity.Entity class is called with no downwards (y direction) motion which is why it sets the OnGround value to false. The problem behind this is pretty complex and I cannot tell what the root cause for this is at the moment. It looks like the the downwards momentum is often 0, but probably at the moment all the updating methods are running it is correct.
I assume the reason why this happens could be that the server sends a packet to update the client position. The client receives the packet while the OnGround value is false (for whatever reasons) and maybe sends back a packet stating that the player is not on the ground.

Is this still an issue in the latest snapshot 16w44a? If so please update the affected versions.

This is an automated comment on any open or reopened issue with out-of-date affected versions.

Confirmed for 1.12.1 and 1.12.2 pre-release

Confirmed in 1.16.1.

onnowhere

(Unassigned)

Confirmed

Platform

Low

Commands

Minecraft 16w03a, Minecraft 16w04a, Minecraft 16w05a, Minecraft 16w05b, Minecraft 16w06a, ..., Minecraft 17w49b, Minecraft 18w50a, 1.15 Pre-Release 2, 1.15 Pre-release 4, 1.16.1

Retrieved