Paper
Paper copied to clipboard
player.getLocation() returns incorrect Y value when riding a mob
Expected behavior
when a player mounts a horse, their y level increases by 0.85, the ride height of the horse, as indicated on their f3 and by running minecraft:tp ~ ~ ~ to get position, this should be reflected by player.getLocation().
Observed/Actual behavior
Calling player.getLocation() returns the y value of the player's vehicles feet as when they are not on the vehicle at all.
Steps/models to reproduce
Check every tick player.getLocation(), mount a horse, at for example y level 60, when you are on the horse it will correctly return your Y level as 60.85, but once you add a saddle, enabling control of the vehicle, the y level glitches between 60.85 and 60.0 randomly.
Plugin and Datapack List
N/A
Paper version
git-Paper-"f090298" (MC: 1.19)
Other
No response
That's a bit of a quirk due to how horses are implemented; the horse kind of becomes the player position that's changed exactly as per player rotation and movement
player#getLocation() just gets the position of the player as far as the server is concerned, as was said on discord, am not sure that there is exactly an issue here given that this is potentially how this has worked for a long time, etc
For now I marked this as a digging deeper issue. Generally it looks like the swapping to the incorrect vehicle location is craft bukkit introduced.
I don't have the time on my hands to look deeper into this right now, hence the label, so input here would be nice. Specifically see https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/nms-patches/net/minecraft/server/network/PlayerConnection.patch#252
Can i be assigned to this issue?
If there issues with the player.getLocation() method returning the wrong Y level when a player is riding a horse in Minecraft, we can try using the Entity#getPassengers() method to get the list of entities riding on the horse, and then check the Y position of the rider entity instead.
Please read the PR, feel free to test it!