[PR #2181] [MERGED] Sleeping follows vanilla's bed rules: creative, obstruction, reach, and the morning skip #4079

Closed
opened 2026-11-03 04:14:31 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2181
Author: @kacpherek
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @ludovic111

Base: main ← Head: fix/sleep-rules


📝 Commits (1)

  • 23d546c Sleep: creative skips the monster check, bed reach and obstruction match vanilla, morning follows the time and weather rules

📊 Changes

1 file changed (+51 additions, -24 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+51 -24)

📄 Description

What and why

Sleeping in a bed did not follow vanilla's rules in four places:

  • A creative player was refused with "there are monsters nearby". Vanilla does not run the monster check for creative players.
  • Beds with something solid above the head or the foot could still be slept in. They now say "This bed is obstructed".
  • Bed reach only looked at the sideways distance to the head. It now allows 3 blocks sideways and 2 blocks up or down, measured to the head or the foot, so a bed on a different floor is out of reach.
  • After a full night, time was always skipped and the weather always reset, even with the daylight cycle or the weather cycle turned off. It also reset the weather timers in clear weather, which re-rolled the next storm. Now time skips only if advance_time is on, and the weather resets only if advance_weather is on and it is raining.

LAN guests go through the same try_sleep and the same morning check, so they get all four fixes.

Vanilla reference

  • ServerPlayer.startSleepInBed: bedInRange, bedBlocked (OBSTRUCTED), spawn point, canSleep, then the monster check only if (!this.isCreative())
  • ServerPlayer.isReachableBedBlock: |dx| <= 3, |dy| <= 2, |dz| <= 3 against the bottom centre of the head or the foot
  • ServerPlayer.bedBlocked and Player.freeAt: the blocks above the head and the foot must not be suffocating
  • ServerLevel.tick: after enough sleepers, the clock moves only if ADVANCE_TIME, then wakeUpAllPlayers, then resetWeatherCycle only if ADVANCE_WEATHER && isRaining()
  • Level.isRaining: rain level above 0.2

Self-check

cargo check -p horizon-client passes.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/2181 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/sleep-rules` --- ### 📝 Commits (1) - [`23d546c`](https://github.com/horizon-rust/horizon/commit/23d546c6d50051ce1ef6e0832cbb452ae9a60ad3) Sleep: creative skips the monster check, bed reach and obstruction match vanilla, morning follows the time and weather rules ### 📊 Changes **1 file changed** (+51 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+51 -24) </details> ### 📄 Description ## What and why Sleeping in a bed did not follow vanilla's rules in four places: - A creative player was refused with "there are monsters nearby". Vanilla does not run the monster check for creative players. - Beds with something solid above the head or the foot could still be slept in. They now say "This bed is obstructed". - Bed reach only looked at the sideways distance to the head. It now allows 3 blocks sideways and 2 blocks up or down, measured to the head or the foot, so a bed on a different floor is out of reach. - After a full night, time was always skipped and the weather always reset, even with the daylight cycle or the weather cycle turned off. It also reset the weather timers in clear weather, which re-rolled the next storm. Now time skips only if `advance_time` is on, and the weather resets only if `advance_weather` is on and it is raining. LAN guests go through the same `try_sleep` and the same morning check, so they get all four fixes. ## Vanilla reference - `ServerPlayer.startSleepInBed`: `bedInRange`, `bedBlocked` (OBSTRUCTED), spawn point, `canSleep`, then the monster check only `if (!this.isCreative())` - `ServerPlayer.isReachableBedBlock`: `|dx| <= 3`, `|dy| <= 2`, `|dz| <= 3` against the bottom centre of the head or the foot - `ServerPlayer.bedBlocked` and `Player.freeAt`: the blocks above the head and the foot must not be suffocating - `ServerLevel.tick`: after enough sleepers, the clock moves only `if ADVANCE_TIME`, then `wakeUpAllPlayers`, then `resetWeatherCycle` only `if ADVANCE_WEATHER && isRaining()` - `Level.isRaining`: rain level above 0.2 ## Self-check `cargo check -p horizon-client` passes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:14:31 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#4079
No description provided.