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
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.
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".
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));
}
...
}
...
Please provide a screenshot of this occurring with your F3 debug screen enabled.