Disclaimer: I do not know if this is a bug or not.
Hostile mobs can and will attack players while they sleep. When they are attacked, they exit bed, as if they left bed on purpose.
What I expected to happen...:
Players in bed are unaffected by hostile mobs.
*What happened...:"
A player was targeted and attacked in bed. After being attacked, the player left the bed.
Steps to Replicate:
Sleep in a bed with a mob somewhat near you (or you can just have some specific mobs next to you, see MC-92719)
Wait to be woken up by being attacked.
Note: It helps if the world is multiplayer (the only mode I could test it in), so that you do not fall asleep immediately.
Once again, I do not know if this is a bug or not. Thank you for your time.
Attachments
Comments 3
I think you are right, but I submitted this to make sure. There is a bug for "you cannot sleep in a bed if you're being attacked by hostile mobs", though, see MC-92719.
I'm pretty sure this is working as intended - you cannot sleep in a bed if you're being attacked by hostile mobs.