The bug
When you have momentum and go to bed, your player is not well placed.
How to reproduce
Jump, run in all directions and right click on the bed to sleep
Observe how your character is in the bed
Example
Here is an example in video:
[media]Related issues
is duplicated by
relates to
Attachments
Comments


Simpler ways to reproduce:
Walk towards the bed as you enter it and you will slide slightly, becoming misaligned.
Sprint towards the bed as you enter it and you will slide even more.
Sprint towards the side of the bed under the Speed II effect and you will slide out of the bed.
I think the same behavior is what is causing the Villagers to become misaligned when they go to sleep.

Not only is my player halfway off the bed, but sometimes one of the arms will be stuck sticking up at an odd angle, like it was frozen in the middle of the walking/sprinting animation.

I've gotten inside my walls.

it can be reproduced easier when flying with elytra and going in bed

In 20w29a
Can confirm in 21w05b.
Can confirm in 1.18.1.

Just wanted everyone to know that this is only visual. On the server, you are put into the correct location
Can confirm in 1.18.2 and 22w13a.
Can confirm in 1.19.
Can confirm in 1.19.2.

Confirmed in 1.19.4. It is even possible to fall out of the bed without having the speed effect.

Confirmed in 23w13a.

Can confirm in 1.20.2

Can confirm in 1.20.6.