Take the 2-minute tour ×
Arqade is a question and answer site for passionate videogamers on all platforms. It's 100% free, no registration required.

In Minecraft, are the monsters that wake you up when you sleep in a bed in an unsafe location monsters that already exist and were moved from a dark location, or are they monsters which are spawned given that the game found a path from a dark location?

share|improve this question
    
Note: This question is obsolete as of Minecraft 1.0.0; if you succeed in going to sleep, you will get a full night's sleep. –  Kevin Reid Dec 7 '11 at 13:51
    
I also noticed that when we were 2 people on the server, only one had to go to sleep in order to cycle back to daytime. Is this a bug, or a feature of 1.0 now? –  Lasse V. Karlsen Dec 7 '11 at 14:18
    
@LasseV.Karlsen Please ask that as a separate question. –  Kevin Reid Dec 7 '11 at 15:06
add comment

3 Answers

up vote 9 down vote accepted

They are newly spawned monsters that can find a path from a location that supports them spawning.

There is some great research on this by bugi74:

Every time bed(s) become active, all players are gone through one by one, each player given 20 tries of spawning a monster. The normal "monsters do not spawn near player" seems to not apply.

On each try it will roll a random monster type from the subset of skeleton, spider or zombie, and a random start location upto +/-32 blocks in horizontal directions and upto +/-16 blocks vertical from the players sleeping location. Then it seeks downwards from that position for the first opaque block below the current block to be checked. Then it tries if the place is suitable for the monster to spawn (water for water mobs, etc.) but no light level check (yet), seeking upwards if the block is not suitable. (There is a limits of 16 blocks above player position for how high it will seek.) Should a suitable location be found, there is another check for if the mob can spawn there, this time with light level check.

Next the algorithm tries to calculate a path from the found spot to the player. If the last point along the path is less than 1.5blocks away from player's position in all three coordinates, the mob gets spawned on a spot very very near the player (like half a block away) (that's what allows the "warp through walls"), and all kinds of things are set in motion (like waking up and aggro), and no further tries are done for that player that time.

The two cases where the monster gets that close to player are when the path is only blocked by one block thick (thin?) wall and the bed (or suitable section of it) is against that wall, or when it really finds a route to the player. No idea how smart the pathing algorithm is - I don't think it is anything near A* or better, judging how stupid they are when trying to get to player in normal situations (luckily for us!).

I've got a Bukkit plugin that manages sleeping with AFK players that caused me to look in to all this myself.

share|improve this answer
    
Thank you! This is a complete answer. In fact, it's also an answer to my question Can you be woken up by a creeper — could you post a version of this answer there? –  Kevin Reid Jun 6 '11 at 16:55
add comment

It is a new mob that spawns to punish you for having a dumb bed location. Easy test;

1) Switch mode to peaceful, this clears out all the monsters

2) Switch back to normal and sleep in an unsafe bed

3) Monster spawns immediately

We can see that this monster is freshly spawned, because time doesn't actually elapse while your sleeping (but instead, the game just sets the time of day to morning), so a mob couldn't have "spawned" followed by "teleported to you". We can witness this lack of time-lapse by noticing that furnaces don't smelt while you're sleeping, for example (this might have been fixed in a recent patch? but I don't think so).

share|improve this answer
add comment

From the Minecraft wiki:

If a hostile mob can get within 2 blocks of the bed, even if the blocks are separated by a wall, you will be awakened with the hostile mob standing next to you. There appears to be a slight delay before the mob attacks you, giving you time to get the first blow.

So it appears that it's not a spawning issue, it's an issue of "can the mob physically get to the 'unsafe to sleep' position from where it spawns".

share|improve this answer
3  
That criteria is used to determine whether a bed is "safe", but the monster that actually appears is a fresh spawn, not something that simply walked up. You can be awoken in a dark, sealed room even though monsters cannot spawn within 24 blocks of the player and cannot simply walk into the room. –  Ben Blank Jun 6 '11 at 1:09
1  
Doesn't that mean that technically "spawning" rules just change when you're sleeping? Since they're now "spawning" within the range that they normally wouldn't be able to. –  Kzqai Jun 6 '11 at 2:19
    
@Ben Blank: If that's true, it's an answer to my question, and please post it as one so I can accept it, but are you certain it's a new mob and not a teleported mob? A description of how you verified this would be much appreciated. –  Kevin Reid Jun 6 '11 at 3:40
    
@Tchalvak — Exactly. @Kevin Reid — I didn't want to post a mostly-duplicate answer that came to the opposite conclusion. I'll try to dig up the relevant section of the source; if I find it before Dave updates his answer, I'll post my own. –  Ben Blank Jun 6 '11 at 4:55
1  
@Ben Blank - only the first @<username> reference currently generates a 'ping' to a given user (just an FYI). –  Raven Dreamer Jun 6 '11 at 6:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.