mojira.dev
MC-193668

'You may not rest now; the bed is too far away' message will appear during the day

The bug

Every time I right-click a bed too far away from it during the day, it will display the You may not rest now; the bed is too far away message.

Code analysis

Code analysis can be found in this comment.

Attachments

Comments 14

Please provide a screenshot of this occurring with your F3 debug screen enabled.

I also had this problem using our vanilla 1.16.1 server. I was having lag issues at the time, just as day was changing to night.

Not sure if a bug or not.

 

I can confirm for 1.16.4 pre-release 1

In 1.15.2 it used to say that you can only sleep at night and during thunderstorms when trying to sleep in a bed during the day when being too far away. Seems like the order in which the error messages are prioritized has changed in 1.16. In 1.16 it prioritizes "You may not rest now; the bed is too far away".

4 more comments

Can confirm in 21w15a.

Can confirm in 1.17.

Can confirm in 1.17.1.

Can confirm in 1.18.2 and 22w18a.

Code analysis (Mojang mappings, 22w18a): in ServerPlayer#startSleepInBed(), the TOO_FAR_AWAY ("...the bed is too far away") warning takes priority over the NOT_POSSIBLE_NOW ("You can sleep only at night...") warning:

net.minecraft.server.level.ServerPlayer.java

...
    @Override
    public Either<Player.BedSleepingProblem, Unit> startSleepInBed(BlockPos $$02) {
        Direction $$1 = this.level.getBlockState($$02).getValue(HorizontalDirectionalBlock.FACING);
        ...
        if (!this.bedInRange($$02, $$1)) {
            return Either.left((Object)((Object)Player.BedSleepingProblem.TOO_FAR_AWAY));
        }
        ...
        if (this.level.isDay()) {
            return Either.left((Object)((Object)Player.BedSleepingProblem.NOT_POSSIBLE_NOW));
        }
        ...
    }
...

Reese Dillimore

(Unassigned)

Confirmed

Player, UI

20w27a, 1.16.4 Pre-release 1, 20w46a, 20w48a, 1.16.5, ..., 1.19.2, 1.19.4, 23w14a, 1.20.1, 1.20.4

Retrieved