[PR #5211] [MERGED] Beds: sample sleeper light at eye height, zero sleeping pitch, and stand beside bed on wake (#5121) #6144

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5211
Author: @mulareal
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: fix-bed-sleep-wakeup-5121


📝 Commits (1)

  • 12cdd1c Beds: sample sleeper light at eye height, zero sleeping pitch, and stand beside bed on wake (#5121)

📊 Changes

8 files changed (+252 additions, -17 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+41 -1)
📝 crates/horizon-client/src/game/lan.rs (+6 -4)
📝 crates/horizon-client/src/game/lan_actions.rs (+63 -5)
📝 crates/horizon-client/src/game/perspective.rs (+50 -5)
📝 crates/horizon-client/src/game/remote.rs (+41 -1)
📝 crates/horizon-client/src/game/respawn_anchor.rs (+35 -0)
📝 crates/horizon-client/src/lan/guest.rs (+2 -0)
📝 crates/horizon-client/src/lan/hub.rs (+14 -1)

📄 Description

🤖 Opened by mulareal's AI agent (Antigravity, Gemini 4 Argon), not by mulareal personally.

What

Sleeping players keep normal lighting under a two-block ceiling, keep their head flat on the pillow even when clicking the bed from close up, and stand up next to the bed facing its head when waking instead of remaining on top of the bed or being forced into crawling under a low ceiling.

Fixes #5121

Why

  • player_model_geometry and guest_model_geometry sampled block and sky light at m.position.y + 1.62 (standing eye height) instead of the current pose's eye height (EntityRenderer.extractRenderState / Entity.getBlockX/getBlockEyeY/getBlockZ). While in bed (y = head_y + 0.6875), adding 1.62 probed head_y + 2—inside the solid ceiling of a two-block-high room where light is 0—darkening the player model.
  • LivingEntity.tick zeroes xRot while isSleeping() is true (if (this.isSleeping()) { this.setXRot(0.0F); }), and LivingEntity.startSleeping, ServerPlayer.startSleeping, and LivingEntity.onSyncedDataUpdated(SLEEPING_POS_ID) snap the sleeper to setPosToBed. Horizon left pitch untouched while sleeping and waited for the next tick to move the sleeper to the bed, so clicking a bed from close up while looking steeply down tilted the sleeping player's head cube upward into the first-person camera.
  • wake_up and Hub::wake cleared sleeping / g.bed without running LivingEntity.stopSleeping (BedBlock.findStandUpPosition, setPos, setDeltaMovement(Vec3.ZERO), and facing the bed head with xRot = 0) or ServerPlayer.stopSleepInBed's connection.teleport, leaving the player at head_y + 0.6875 on top of the bed block (where canPlayerFitWithinBlocksAndEntitiesWhen(Pose.STANDING) fails under a two-block ceiling and forces Pose.SWIMMING).

Fix

  • Sample the player and LAN guest model light at (m.position.y + eye).floor() using the current pose's eye_height in player_model_geometry and entity_light_block (perspective.rs) and guest_model_geometry (game/lan.rs).
  • Move the sleeper to setPosToBed and zero pitch (xRot) on entering the bed and on each sleeping tick in try_sleep and tick_sleep (game.rs), as_guest and guest_sleep_tick (game/lan_actions.rs), and handle_packet / tick_remote / tick_remote_entities (game/remote.rs).
  • Compute the stand-up position and bed-head yaw in bed_wake_pose (game/respawn_anchor.rs) and apply it with a teleport when waking in wake_up (game.rs), Hub::wake (lan/hub.rs), and wake_guest_from, wake_woken_guests, wake_guest, and wake_guests (game/lan_actions.rs).

Checked

  • cargo test -p horizon-client --bin horizon-client sleeping_player_light_probe_stays_below_a_two_block_ceiling
  • In-game verification (horizon-client with --world BedTest5121 --creative):
    • Placed a bed inside a 2-block-high room, clicked it from directly adjacent while looking steeply down: the player model stays lit, the head stays flat below the camera, and waking up places the player standing beside the bed facing the headboard.
Check Result
Scope ✅ 8 files, +228 −18
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 484 passed
rustfmt ✅
clippy (horizon-client) ✅
tests: horizon-client ✅ 1339 passed
doc tests ✅ 0 passed
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses

🤖 Generated with Antigravity


🔄 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/5211 **Author:** [@mulareal](https://github.com/mulareal) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix-bed-sleep-wakeup-5121` --- ### 📝 Commits (1) - [`12cdd1c`](https://github.com/horizon-rust/horizon/commit/12cdd1c6fe461b41a82a03ad7f74b13e7fbe0d81) Beds: sample sleeper light at eye height, zero sleeping pitch, and stand beside bed on wake (#5121) ### 📊 Changes **8 files changed** (+252 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+41 -1) 📝 `crates/horizon-client/src/game/lan.rs` (+6 -4) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+63 -5) 📝 `crates/horizon-client/src/game/perspective.rs` (+50 -5) 📝 `crates/horizon-client/src/game/remote.rs` (+41 -1) 📝 `crates/horizon-client/src/game/respawn_anchor.rs` (+35 -0) 📝 `crates/horizon-client/src/lan/guest.rs` (+2 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+14 -1) </details> ### 📄 Description > 🤖 Opened by mulareal's AI agent (Antigravity, Gemini 4 Argon), not by mulareal personally. ## What Sleeping players keep normal lighting under a two-block ceiling, keep their head flat on the pillow even when clicking the bed from close up, and stand up next to the bed facing its head when waking instead of remaining on top of the bed or being forced into crawling under a low ceiling. Fixes #5121 ## Why - `player_model_geometry` and `guest_model_geometry` sampled block and sky light at `m.position.y + 1.62` (standing eye height) instead of the current pose's eye height (`EntityRenderer.extractRenderState` / `Entity.getBlockX/getBlockEyeY/getBlockZ`). While in bed (`y = head_y + 0.6875`), adding `1.62` probed `head_y + 2`—inside the solid ceiling of a two-block-high room where light is `0`—darkening the player model. - `LivingEntity.tick` zeroes `xRot` while `isSleeping()` is true (`if (this.isSleeping()) { this.setXRot(0.0F); }`), and `LivingEntity.startSleeping`, `ServerPlayer.startSleeping`, and `LivingEntity.onSyncedDataUpdated(SLEEPING_POS_ID)` snap the sleeper to `setPosToBed`. Horizon left `pitch` untouched while sleeping and waited for the next tick to move the sleeper to the bed, so clicking a bed from close up while looking steeply down tilted the sleeping player's head cube upward into the first-person camera. - `wake_up` and `Hub::wake` cleared `sleeping` / `g.bed` without running `LivingEntity.stopSleeping` (`BedBlock.findStandUpPosition`, `setPos`, `setDeltaMovement(Vec3.ZERO)`, and facing the bed head with `xRot = 0`) or `ServerPlayer.stopSleepInBed`'s `connection.teleport`, leaving the player at `head_y + 0.6875` on top of the bed block (where `canPlayerFitWithinBlocksAndEntitiesWhen(Pose.STANDING)` fails under a two-block ceiling and forces `Pose.SWIMMING`). ## Fix - Sample the player and LAN guest model light at `(m.position.y + eye).floor()` using the current pose's `eye_height` in `player_model_geometry` and `entity_light_block` (`perspective.rs`) and `guest_model_geometry` (`game/lan.rs`). - Move the sleeper to `setPosToBed` and zero `pitch` (`xRot`) on entering the bed and on each sleeping tick in `try_sleep` and `tick_sleep` (`game.rs`), `as_guest` and `guest_sleep_tick` (`game/lan_actions.rs`), and `handle_packet` / `tick_remote` / `tick_remote_entities` (`game/remote.rs`). - Compute the stand-up position and bed-head yaw in `bed_wake_pose` (`game/respawn_anchor.rs`) and apply it with a teleport when waking in `wake_up` (`game.rs`), `Hub::wake` (`lan/hub.rs`), and `wake_guest_from`, `wake_woken_guests`, `wake_guest`, and `wake_guests` (`game/lan_actions.rs`). ## Checked - `cargo test -p horizon-client --bin horizon-client sleeping_player_light_probe_stays_below_a_two_block_ceiling` - In-game verification (`horizon-client` with `--world BedTest5121 --creative`): - Placed a bed inside a 2-block-high room, clicked it from directly adjacent while looking steeply down: the player model stays lit, the head stays flat below the camera, and waking up places the player standing beside the bed facing the headboard. | Check | Result | |---|---| | Scope | ✅ 8 files, +228 −18 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 484 passed | | rustfmt | ✅ | | clippy (`horizon-client`) | ✅ | | tests: horizon-client | ✅ 1339 passed | | doc tests | ✅ 0 passed | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | 🤖 Generated with [Antigravity](https://antigravity.google) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:14:54 +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#6144
No description provided.