You mean you get mobs appearing in your bedroom while you sleep?
Some of my tips, other members may be able to offer more:
1: Ensure your room is lighted up enough.
2: Ensure that if there is dirt/grass outside your room, light this up aswel.
3: Place your bed away from a wall, so that it is not touching a block that is also an outside wall block. (This worked for me)
4: Turn it on peaceful.
All you have to do is be completely surrounded in a room wtih torches set up around it. Also, you must only have a single door. If you have a double door enemies will come into your room while you sleep. The only fix for that is to put some kind of blocks in front of the double door. I used to use dirt. It may seem stupid, but thats how the game is.
I always have the bed against a wall (usually the head of the bed, rather than the side).
Don't make your bedroom too big. 5x5 is big enough
make sure you have a torch or four in there
make sure the floor is NOT dirt. Animals spawn on dirt. Don't need that.
make sure you have a single door and that it is closed (so monsters aren't walking in). I always put down a pressure plate on the floor to help make sure it is closed.
sleep right away at dusk. the longer you want, monsters are more likely to spawn. It is possible to keep this up, such that when you go out in the morning, no monsters have spawned outside because the game never got the chance to spawn them because the light level never went low enough.
We have a couple seeds this happens in and still does since the update. All we do is block the door(s) with gravel, dirt, or sand, and place a torch on every available block on the floor. You will still need to light the room normally along the walls/ceiling, but the torches on the floor prevent anything from spawning in the room because the block is "occupied" by the torch. Good luck!
Private Mod Note
Rollback Post to RevisionRollBack
~My problem is a simple one: I'm severely allergic to stupid.~
Never had any problem with that. I even have houses with open tunnels (no doors or any obstacle!) to bedrock and cave systems and always sleep unmolested. Just keep everything nice lit and the exits to the surface shut and you will be fine.
P.S.: Oh and keep your bed at least 2 blocks away from every wall.
You are going to need some torches. Make sure you aren't sleeping the dark. Now, I am not saying to put torches every possible place. (Even though that might work.) Stay away from any walls when you sleep in your bed. You should be good to go.