mojira.dev
MC-15125

Cannot wake up safely from bed despite seemingly enough space to do so.

tl;dr:
A bed placed in a 1x2x2 space with a chest in the floor at the foot end of the bed spawns the player with it's head in the ceiling.
---------------------------------------------------------------

This bug relates to MC-9529, however we see that no half-slab need to be involved here, and that there IS enough available air block space that SHOULD allow waking up safely.

BUG EFFECT: When waking up from sleeping in a bed, EVEN if there is an available air block beside the bed, if that air block is not over a solid block then it won't be considered a valid "bed exit" block, making the player wake up on the bed itself. Now, when the roof is 3 high that isn't a problem. However, when the roof is only 2 high, this causes suffocation and if the player can't break the block his head is stuck inside in time, then he dies.

See images below:

1st image: Setup, bed with an air block at it's feet, however that air block is over a transparent block, here a chest.

2nd image: The view from sleeping in the bed.

3rd image: View upon waking up. Instead of waking up safely at the feet of the bed, we wake up with our head in the roof. Here I chose to make the roof out of glowstone because for some reason Steve doesn't seem to suffocate when his head is stuck inside it.

4th image: Same position, looking downward a bit.

5th image: Same position, after breaking the glowstone.

> Block attributes I use am using here:

'Pass-through' block: if a block type allows movement in all directions, then it has that flag set. Includes all blocks that don't have hitboxes. Examples: Air, most small vegetation like roses, saplings and crops, vines, paintings, item frames, etc.

'Half-block': Any block type that will block movement only in either it's upper half or lower half will have this flag set plus a way to know which half of the block is filled. This attribute is often prefixed with "lower or upper" to indicate which half is filled.

> Suggested fix:

When checking for places to let the player out of a bed, the condition should not be:

"Both feet and head in an air block, and feet over a solid block."

but should be instead

"Both feet and head in an air block, and feet NOT over a 'pass-through' block"

A more "detailed" condition could be:

IF
head in a pass-through block, and feet in a pass-through block, and feet not over a pass-through block
THEN
This is a valid 'primary importance' exit spot.
OTHERWISE IF
head in a upper-half-block, and feet in a pass-through block, and feet over a lower-half-block
THEN
This is a valid 'secondary importance' exit spot.

(in short the game should checks all potential exist spots in order of ideal preference, and stops going through the list when it finds a good spot).

And in all cases, upon waking up, if the block below is a half-block, then the player appears in the block below already at the 'half-block' elevation (instead of dropping by one half block)

Also, spots to be checked should be all those around the bed (ortogonally) PLUS ALSO all those around the bed but at a +1 elevation (total of 12 potential exit spots). If all that fails, then the 2 spots rght above the bed are checked.

Also, all exit spots should also be checked when trying to GO TO SLEEP, and if no valid spot is found then the "switch player position to bed's position" should actually be completely prevented with this chat message:

"Cannot rest when there is no place to wake up from the bed."

> Conclusion:

This would allow players to be able to place "recessed" beds (aka "japanese style" beds) (ok, that part is more like a feature request not a bug per se) and would also fix most of these suffocation problems (this really adresses the "this is a feature not a bug" part).

Linked issues

Attachments

Comments 7

I want to relate another story, just in case it's the same issue, to avoid having to open yet another duplicate.

I had built my bed with one square of air around each side except for the head, which worked fine. Later, I had mined out the blocks underneath the bed, planning to replace the floor material, only I had forgotten to bring the replacement. Getting the replacement required going outside and it was night, so I went to sleep. On awaking, I was placed inside stone somewhere and died. It was a hardcore playthrough so I didn't get a chance to investigate exactly where I got placed.

Still happens in 1.7.9.

Suggested fix:

When the algorithm searches for a valid exit point, instead of:

SET valid spot to right over the bed
LOOP through all potential exit spots
IF ( exit spot is Air AND exit spot is under Air AND exit spot is over Solid ) THEN: SET valid spot to exit spot, and exit loop immediately
CONTINUE LOOP
Return valid spot.

Note: "exit spot' corresponds to the player FEET coordinates not his head.

Replace with:

SET primary valid spot to right over the bed
SET secondary valid spot to right over the bed
LOOP thought all potential exit spots:
IF (exit spot is Air AND exit spot is under Air AND exit spot is over non-Air ) THEN:
IF (exit spot is over Solid) THEN : SET primary valid spot to exit spot and exit loop immediately
ELSEIF //comment: we have the exit spot inf free air space but over a non-Air non-solid block
IF ( 2 blocks under exit spot is a solid block ) THEN: SET secondary valid spot to exit spot, however continue the loop
CONTINUE LOOP
IF primary valid spot is right over the bed: SET primary valid spot = to secondary valid spot.
Return primary valid spot.

Is this still a concern in the current Minecraft version 1.8.1 Prerelease 3 / Launcher version 1.5.3 or later? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

No response for over a year.

Patrick Rannou

(Unassigned)

Confirmed

bed, suffocation

Minecraft 1.5.2, Snapshot 13w18c, Minecraft 1.7.9

Retrieved