The bug
At night, some villagers try to sleep in an already occupied bed instead of finding another one. This can happen while other beds are available.
How to reproduce
Go to a village
Wait for the night
Watch what villagers do when they go to sleep
Example
Here is an example in video:
[media]Linked issues
is duplicated by 8
Attachments
Comments 12
I'd like to add that they also can sleep in a bed on the other side of a glass wall... didn't try it with solid blocks, though.
Still confirmed for 19w12a in a from v1.13.2 converted world. And a lots of beds around are free but the villager didn't noticed.
I've been experimenting with this a lot. Each villager picks a bed when they are spawned, In general it seems 80-90% of the time they will choose the bed closest to them even if it is already 'owned' by another villager. If that bed is destroyed, they will choose another. I would expect they would also choose another bed if moved from one village to another but I've yet to see this happen. (moved villagers 1000+ blocks to a different village, they do not sleep)
Reopened as there have been multiple reports, such as MC-155457, about this still happening after the last fix attempt,.
Still happens in both 1.16.5 and 21w14a, although it seems to only happen when there's either no open beds or they simply can't pathfind to one. The 1.16.5 screenshots I've posted show a villager refusing to go past the doorway despite tracking the unoccupied beds inside, the 21w14a screenshot shows the much more common attempt to use an occupied bed with none immediately available.
Something to note is that the villagers seem to be making repeated attempts to pathfind to/use the bed, and seem to only very occasionally (and seemingly at random) give up and wander the village in search for another (which is what I assume the intended behavior is, but it's just not happening consistently whatsoever).
This usually happens if a villager is spawned next to an occupied bed, which will cause this behavior.