[PR #4020] [MERGED] Sleeping: lie 0.125 above the bed's top, as vanilla does #5360

Closed
opened 2026-11-03 05:12:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4020
Author: @DenisHumen
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: fix/sleep-camera


📝 Commits (1)

  • c3e9ec5 Sleeping: lie 0.125 above the bed's top, as vanilla does

📊 Changes

4 files changed (+8 additions, -4 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+2 -1)
📝 crates/horizon-client/src/game/lan_actions.rs (+2 -1)
📝 crates/horizon-client/src/game/remote.rs (+2 -1)
📝 crates/horizon-client/src/mobs/villager.rs (+2 -1)

📄 Description

🤖 Opened by DenisHumen's AI agent (Claude Code, Opus 5.5), not by DenisHumen personally.

What

A sleeping player now lies at vanilla's height, 0.125 above the bed's top. Before, the player lay 0.125 too low, so the first-person camera ended up inside the player's own head (#4006). Sleeping villagers and wandering traders lie at the same height.

Fixes #4006

Why

LivingEntity.setPosToBed(height, pos) sets the position to (x + 0.5, y + height + 0.125, z + 0.5). height is AbstractBedBlock.getSleepHeight, the top of the bed's shape (VoxelShape.max(Y), 0.5625 for a bed). Read from the 26.3 jar with javap.

Horizon put sleepers at y + 0.5625 in four places, without the 0.125:

  • the local player (game.rs);
  • a server's players (lan_actions.rs);
  • a server's client (remote.rs);
  • villagers (mobs/villager.rs).

The camera's sleeping offset (Camera.alignWithEntity: eye 0.2, then move(0, 0.15, 0)) already matched vanilla, so with the lower body it sat inside the head.

Checked

  • In game, fast build with a scratch home and horizon-ctl: a bed at 0 100 0/0 100 1, night, interact with the bed, then state.
    • Before (main): sleeper at y 100.5625, eye 100.7625.
    • After: y 100.6875, eye 100.8875, as setPosToBed gives.
  • pr_ready, two failures unrelated to this change:
    • entity_nbt::axolotl_nbt_tests::bucket_cooldown_… also fails on main (#3840, fixed by #3851).
    • title::tests::each_world_preset_writes_its_own_generator fails here with a Windows NotADirectory (os error 267) in a test about world presets.
    • The clippy failure comes from lints new in clippy 1.96, in code this PR doesn't touch.
    • Parity can't start on Windows (tools/parity.py imports fcntl).

pr_ready (tools/pr_ready.py --base upstream/main on DenisPC, against upstream/main at 1884052ed, 3 min 8 s)

Check Result
Scope ✅ 5 files, +9 −4
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 475 passed (53 s)
rustfmt ✅ (7 s)
clippy ❌ failed (12 s)
tests: horizon-client ❌ 683 passed, 2 failed (1 min 50 s)
doc tests ✅ 0 passed (1 s)
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 ❌ 362 affected, (1 s)
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Claude Code


🔄 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/4020 **Author:** [@DenisHumen](https://github.com/DenisHumen) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/sleep-camera` --- ### 📝 Commits (1) - [`c3e9ec5`](https://github.com/horizon-rust/horizon/commit/c3e9ec54a957c3e924bb77d92a591de4baaa5eb3) Sleeping: lie 0.125 above the bed's top, as vanilla does ### 📊 Changes **4 files changed** (+8 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+2 -1) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+2 -1) 📝 `crates/horizon-client/src/game/remote.rs` (+2 -1) 📝 `crates/horizon-client/src/mobs/villager.rs` (+2 -1) </details> ### 📄 Description > 🤖 Opened by DenisHumen's AI agent (Claude Code, Opus 5.5), not by DenisHumen personally. ## What A sleeping player now lies at vanilla's height, 0.125 above the bed's top. Before, the player lay 0.125 too low, so the first-person camera ended up inside the player's own head (#4006). Sleeping villagers and wandering traders lie at the same height. Fixes #4006 ## Why `LivingEntity.setPosToBed(height, pos)` sets the position to `(x + 0.5, y + height + 0.125, z + 0.5)`. `height` is `AbstractBedBlock.getSleepHeight`, the top of the bed's shape (`VoxelShape.max(Y)`, 0.5625 for a bed). Read from the 26.3 jar with `javap`. Horizon put sleepers at `y + 0.5625` in four places, without the 0.125: - the local player (`game.rs`); - a server's players (`lan_actions.rs`); - a server's client (`remote.rs`); - villagers (`mobs/villager.rs`). The camera's sleeping offset (`Camera.alignWithEntity`: eye 0.2, then `move(0, 0.15, 0)`) already matched vanilla, so with the lower body it sat inside the head. ## Checked - In game, fast build with a scratch home and `horizon-ctl`: a bed at `0 100 0`/`0 100 1`, night, `interact` with the bed, then `state`. - Before (`main`): sleeper at y `100.5625`, eye `100.7625`. - After: y `100.6875`, eye `100.8875`, as `setPosToBed` gives. - pr_ready, two failures unrelated to this change: - `entity_nbt::axolotl_nbt_tests::bucket_cooldown_…` also fails on `main` (#3840, fixed by #3851). - `title::tests::each_world_preset_writes_its_own_generator` fails here with a Windows `NotADirectory` (os error 267) in a test about world presets. - The clippy failure comes from lints new in clippy 1.96, in code this PR doesn't touch. - Parity can't start on Windows (`tools/parity.py` imports `fcntl`). **pr_ready** (`tools/pr_ready.py --base upstream/main` on DenisPC, against upstream/main at 1884052ed, 3 min 8 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +9 −4 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 475 passed (53 s) | | rustfmt | ✅ (7 s) | | clippy | ❌ failed (12 s) | | tests: horizon-client | ❌ 683 passed, 2 failed (1 min 50 s) | | doc tests | ✅ 0 passed (1 s) | | 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 | ❌ 362 affected, (1 s) | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:12:03 +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#5360
No description provided.