mojira.dev
MC-309824

The game will froze sometimes when player sleep on the only head part of a straw bed

When player use /setblock ~ ~ ~ straw_bed[part=head](where the lower part of the bed should be the air), then sleep, the game will give you a void damage type or just the whole game be frozen(not crash).

As the players' survey, they found:

When the player lies down on the bed, the right-click part of the bed will call the method

LivingEntity.setPosToBed(blockState, bedPosition)

which is to set the coordinates where the player will sleep.

The y-axis coordinate equals to:

bedPosition.getY() + sleepHeight + 0.125

which is the position of the bed frame + the shape and height of the bed + 0.125.

For an ordinary bed, the upper part and the lower part have the same shape, so they returns their original shape and height by themselves;

For a straw bed, the upper part and the lower part have not the same shape, so the programmers coded a special condition determination:

If the player right-clicks on the upper part of the straw bed, then the lower part should return to the highest shape height of the corresponding block. In this way, the height at which the player sleeps is the lower part of the bed.

But if the lower bed was air, due to its shape is empty, the method

VoxelShape.max(Y)

returns the value

Double.NEGATIVE_INFINITY

and substitute the value, the y-axis becomes negative infinity.

For sometimes, the game will force the y-axis in the original coordinate, but more often, the game will just froze.

The datas are from other platforms.

Steps to reproduce the issue

/setblock ~ ~ ~ straw_bed[part=head], then sleep

Expected result

The game will sleep ordinarily and had the achievement Sweet Dreams

Actual result

The game frozed or give a void damage

This bug is the same as MC-309685, but more detailed.

Linked issues

Comments 1

Resolving as a dupe of MC-309685 as you have stated. Please add the detail into a comment as that issue has already been triaged

drgum cltrie

(Unassigned)

Unconfirmed

26.3 Snapshot 3

Retrieved