Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Player.getBodyYaw() not updating when player strafe

Open Snoop1CattZ69 opened this issue 1 year ago • 4 comments

Expected behavior

Player bodyYaw updation after strafing without head moving, but nothing changes.

Observed/Actual behavior

When I strafe to left/right direction, visual body rotation was changed, but the Player.getBodyYaw value was same as before moving

Steps/models to reproduce

Just tap on keyboard to move your player left/right

Plugin and Datapack List

Only what I've written for testing.

Paper version

This server is running Paper version git-Paper-477 (MC: 1.19.4) (Implementing API version 1.19.4-R0.1-SNAPSHOT) (Git: 5c78e77) Previous version: git-Paper-404 (MC: 1.19.3)

Other

Additionally: BodyYaw value can grow below -180 and higher than +180

Snoop1CattZ69 avatar Mar 29 '23 07:03 Snoop1CattZ69

how can I contribute to this issue?

hendoulmou9 avatar Mar 30 '23 20:03 hendoulmou9

replicable on latest build from a v quick look, issue is nms entity move functions don't appear to update yBodyRot - api impl appears to be primarily for vehicles

TheRealRyGuy avatar Mar 30 '23 20:03 TheRealRyGuy

If the 'bodyYaw' value is not updating correctly after strafing. This could be because the 'bodyYaw' value is not being updated in the Entity class when the player strafes. We can create a custom event listener that listens for the player's movement and updates the bodyYaw value accordingly. This listener listens for PlayerMoveEvents and updates the player's yaw and bodyYaw values based on the change in the player's position. And we use atan2(-deltaX, deltaZ) to ensure that the rotation is correct regardless of the player's direction of movement.

hendoulmou9 avatar Mar 31 '23 07:03 hendoulmou9

If the 'bodyYaw' value is not updating correctly after strafing. This could be because the 'bodyYaw' value is not being updated in the Entity class when the player strafes. We can create a custom event listener that listens for the player's movement and updates the bodyYaw value accordingly. This listener listens for PlayerMoveEvents and updates the player's yaw and bodyYaw values based on the change in the player's position. And we use atan2(-deltaX, deltaZ) to ensure that the rotation is correct regardless of the player's direction of movement.

This is not a good solution for me, required solution will update a lot of data depends on bodyYaw, checking move event will ensure a big impact to performance.

Snoop1CattZ69 avatar Mar 31 '23 20:03 Snoop1CattZ69