Skip to content

Instantly share code, notes, and snippets.

@NEZNAMY
Last active August 22, 2023 19:14
Show Gist options
  • Save NEZNAMY/33c296f113fb9bf712c8710af0c91c6b to your computer and use it in GitHub Desktop.
Save NEZNAMY/33c296f113fb9bf712c8710af0c91c6b to your computer and use it in GitHub Desktop.
Player position bug when riding an animal

About

When a player is riding a camel, their Y position is not only wrong, but it is constantly flickering between Y value of the vehicle and player's Y, even when not moving at all. Video example.
When tested on a terrain with base height 74, when riding a camel, height in F3 shows 75.425, but API output flickers between 74 and 75.425.
This issue only affects 1.20.x Bukkit-based servers, it works fine on Fabric.

Sync vs async access

The result of Player#getLocation().getY() is only wrong when accessed asychronously. When accessed in the server thread, it returns the vehicle's Y instead of player's. However, when using a command, it is still sometimes wrong even though commands are processed in server thread.
image

Result on other animals

On pigs, player's height properly reflects what F3 says.
On donkeys, base Y is returned instead (74) and value sometimes flickers even in sync access. Example sequence:
Frame 1:
image
Frame 2:
image
Frame 3:
image
Haven't tested other animals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment