[PR #3016] [CLOSED] Sleeping: villagers lie on the pillow, the player's body shows in bed, a bed wakes its villager #4757

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3016
Author: @ASOwnerYT
Created: 10/27/2026
Status: ❌ Closed

Base: main ← Head: claude/sleeping-position-visibility-6ede41


📝 Commits (3)

  • fbff4e6 Sleeping: villagers lie on the pillow, the player's body shows, beds wake villagers
  • d8833bc lan_e2e: sleep-villager, a bed wakes its villager and the sleeper's body shows
  • 75760ba Merge main: #3037 already brought this branch's changes

📄 Description

🤖 Opened by asowneryt's AI agent (Claude Code), not by asowneryt himself.

What and why

Three bugs with sleeping, reported by asowneryt with screenshots:

  1. A sleeping villager lay past the end of its bed. The bed's rotation was right, but the body's feet were on the pillow and its head stuck out past the head of the bed. base_transform_at moves a sleeper toward the foot by its eye height minus 0.1. For a villager it read eye_y() - position.y, and while asleep that's the 0.2 of its sleeping box (LivingEntity.SLEEPING_DIMENSIONS). So it moved 0.1 instead of vanilla's 1.52. Mob::dims now calls a new awake_dims (the same dimensions without the sleeping box), and the renderer takes the eye height from that, as vanilla's getEyeHeight(Pose.STANDING).
  2. The player was invisible while sleeping, in third person too. player_model_shown hid the model whenever sleeping was set. Vanilla skips the camera entity only when the camera isn't detached and the entity isn't sleeping. So the body shows in third person, and in first person while asleep (you see yourself lying down). The new own_body_in_view holds that rule for the model, the shader-pack player span and the player's flames. tick_player_model now gives the model its bed facing (ints[1], as other players' models get), so it lies in the bed.
  3. Using a bed a villager slept in did not wake the villager. The player lay down in the same bed. try_sleep now calls kick_villager_out_of_bed first: the first sleeping villager whose box touches the head block gets up (villager::stop_sleeping, plus LAST_WOKEN as Villager.stopSleeping does), and the player stays up. The next use lies down.

Vanilla decides (3) with the bed's occupied property, which Horizon never sets: neither villagers nor players write it. Writing it needs every way out of a bed to clear it (waking, death, a guest leaving, the bed broken). It also needs sleeping villagers to be saved (SleepingX/Y/Z, which Horizon doesn't write yet), or a world saved mid-night would load with beds that say "occupied" forever. So this PR wakes the villager the way vanilla's kickVillagerOutOfBed does, and leaves occupied for its own PR. Two players can still share a bed until then.

Things I checked and left alone: a sleeper's position (bed top + 0.5625) is what vanilla ends up at too. setPosToBed puts it 0.125 higher, then travel drops the 0.2-high box onto the bed. A villager's one-tick drift as it lies down is also vanilla's: navigation, then the brain, then the move control, in the same order.

status (horizon-ctl) gets server.own_body: whether the world view draws the player's own body.

Vanilla reference

  • LivingEntityRenderer.submit (the sleeper's offset by eyeHeight - 0.1 toward the foot), setupRotations / sleepDirectionToRotation, and extractRenderState (state.eyeHeight = entity.getEyeHeight(Pose.STANDING) for a sleeper).
  • LevelExtractor: an entity is extracted unless it is the camera entity, the camera isn't detached and the entity isn't isSleeping().
  • AbstractBedBlock.useWithoutItem (an occupied bed: kickVillagerOutOfBed, else block.minecraft.bed.occupied; either way no startSleepInBed), kickVillagerOutOfBed (getEntitiesOfClass(Villager.class, new AABB(pos), LivingEntity::isSleeping), the first stopSleeping()), and Villager.stopSleeping (LAST_WOKEN).
  • LivingEntity.startSleeping / setPosToBed / stopSleeping, read for the position and occupied notes above.

Tests:

  • lan_e2e --check sleep-villager (new): a villager lies down in the guest's bed at night, then the guest uses the bed. The villager gets up and the guest stays up; the next use puts the guest to sleep. own_body is true in bed (first person) and false once up again. Passes on the server thread and with --in-frame.
  • Unit test a_sleeper_lies_by_its_standing_eye_height.
  • Checked in game with horizon-ctl (offscreen, fresh homes) on both single-player paths: the villager's head is on the pillow, the player lies in the bed in third person, and the first click on an occupied bed wakes the villager.

Self-check

Full run on the first commit (the fixes). entity_model fails only on its oracle: the bat's IllegalAccessException, as on main (#2941 fixes it); 0 layers differ from vanilla. mob_ai timed out while a LAN check ran beside it. Run again alone, its vanilla oracle ran out of heap (java.lang.OutOfMemoryError: Java heap space under -Xmx4g), before any comparison with Horizon. That side is plain vanilla, so it's this machine, not this branch; please let CI's parity run decide that one.

pr_ready (tools/pr_ready.py --base upstream/main on cachyos, against upstream/main at 795490271, 66 min 26 s)

Check Result
Scope ✅ 6 files, +54 −5
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ✅ 398 passed (19 s)
rustfmt ✅ (4 s)
clippy ✅ (1 min 20 s)
tests: horizon-client ✅ 1257 passed (2 min 6 s)
doc tests ✅ 0 passed (21 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 ❌ 61 affected, 58 passed, failed: entity_model, mob_ai (62 min 9 s)
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The whole branch (with the sleep-villager check and own_body):

pr_ready (tools/pr_ready.py --quick --base upstream/main on cachyos, against upstream/main at 795490271, 1 min 31 s)

Check Result
Scope ✅ 8 files, +112 −8
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ✅ 398 passed (19 s)
rustfmt ✅ (5 s)
clippy ✅
tests: horizon-client ✅ 1257 passed (59 s)
doc tests ✅ 0 passed (1 s)
Parity ➖ 57 affected, to run in CI (--quick)
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Label: none (a fix). This fork can't set labels upstream.

Screenshots

Before: in the report, the player is missing from the third-person view in bed and the villager lies past the bed.
image
image

After: the villager lies on the pillow, and in third person the player lies in the bed with the woken villager beside it
image
image

🤖 Generated by an AI agent. Edited by ASOwnerYT.


🔄 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/3016 **Author:** [@ASOwnerYT](https://github.com/ASOwnerYT) **Created:** 10/27/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `claude/sleeping-position-visibility-6ede41` --- ### 📝 Commits (3) - [`fbff4e6`](https://github.com/horizon-rust/horizon/commit/fbff4e6570b79cc6ec13c00116205417999cb6de) Sleeping: villagers lie on the pillow, the player's body shows, beds wake villagers - [`d8833bc`](https://github.com/horizon-rust/horizon/commit/d8833bc666e09dd3a79263c9862543e05f0fa5ec) lan_e2e: sleep-villager, a bed wakes its villager and the sleeper's body shows - [`75760ba`](https://github.com/horizon-rust/horizon/commit/75760ba30c0953e1ca616d304897ac65698ca857) Merge main: #3037 already brought this branch's changes ### 📄 Description > 🤖 Opened by asowneryt's AI agent (Claude Code), not by asowneryt himself. ## What and why Three bugs with sleeping, reported by asowneryt with screenshots: 1. **A sleeping villager lay past the end of its bed.** The bed's rotation was right, but the body's feet were on the pillow and its head stuck out past the head of the bed. `base_transform_at` moves a sleeper toward the foot by its eye height minus 0.1. For a villager it read `eye_y() - position.y`, and while asleep that's the 0.2 of its sleeping box (`LivingEntity.SLEEPING_DIMENSIONS`). So it moved 0.1 instead of vanilla's 1.52. `Mob::dims` now calls a new `awake_dims` (the same dimensions without the sleeping box), and the renderer takes the eye height from that, as vanilla's `getEyeHeight(Pose.STANDING)`. 2. **The player was invisible while sleeping, in third person too.** `player_model_shown` hid the model whenever `sleeping` was set. Vanilla skips the camera entity only when the camera isn't detached and the entity isn't sleeping. So the body shows in third person, and in first person while asleep (you see yourself lying down). The new `own_body_in_view` holds that rule for the model, the shader-pack player span and the player's flames. `tick_player_model` now gives the model its bed facing (`ints[1]`, as other players' models get), so it lies in the bed. 3. **Using a bed a villager slept in did not wake the villager.** The player lay down in the same bed. `try_sleep` now calls `kick_villager_out_of_bed` first: the first sleeping villager whose box touches the head block gets up (`villager::stop_sleeping`, plus `LAST_WOKEN` as `Villager.stopSleeping` does), and the player stays up. The next use lies down. Vanilla decides (3) with the bed's `occupied` property, which Horizon never sets: neither villagers nor players write it. Writing it needs every way out of a bed to clear it (waking, death, a guest leaving, the bed broken). It also needs sleeping villagers to be saved (`SleepingX/Y/Z`, which Horizon doesn't write yet), or a world saved mid-night would load with beds that say "occupied" forever. So this PR wakes the villager the way vanilla's `kickVillagerOutOfBed` does, and leaves `occupied` for its own PR. Two players can still share a bed until then. Things I checked and left alone: a sleeper's position (bed top + 0.5625) is what vanilla ends up at too. `setPosToBed` puts it 0.125 higher, then `travel` drops the 0.2-high box onto the bed. A villager's one-tick drift as it lies down is also vanilla's: navigation, then the brain, then the move control, in the same order. `status` (horizon-ctl) gets `server.own_body`: whether the world view draws the player's own body. ## Vanilla reference - `LivingEntityRenderer.submit` (the sleeper's offset by `eyeHeight - 0.1` toward the foot), `setupRotations` / `sleepDirectionToRotation`, and `extractRenderState` (`state.eyeHeight = entity.getEyeHeight(Pose.STANDING)` for a sleeper). - `LevelExtractor`: an entity is extracted unless it is the camera entity, the camera isn't detached and the entity isn't `isSleeping()`. - `AbstractBedBlock.useWithoutItem` (an occupied bed: `kickVillagerOutOfBed`, else `block.minecraft.bed.occupied`; either way no `startSleepInBed`), `kickVillagerOutOfBed` (`getEntitiesOfClass(Villager.class, new AABB(pos), LivingEntity::isSleeping)`, the first `stopSleeping()`), and `Villager.stopSleeping` (`LAST_WOKEN`). - `LivingEntity.startSleeping` / `setPosToBed` / `stopSleeping`, read for the position and `occupied` notes above. Tests: - `lan_e2e --check sleep-villager` (new): a villager lies down in the guest's bed at night, then the guest uses the bed. The villager gets up and the guest stays up; the next use puts the guest to sleep. `own_body` is true in bed (first person) and false once up again. Passes on the server thread and with `--in-frame`. - Unit test `a_sleeper_lies_by_its_standing_eye_height`. - Checked in game with horizon-ctl (offscreen, fresh homes) on both single-player paths: the villager's head is on the pillow, the player lies in the bed in third person, and the first click on an occupied bed wakes the villager. ## Self-check Full run on the first commit (the fixes). `entity_model` fails only on its oracle: the bat's `IllegalAccessException`, as on main (#2941 fixes it); 0 layers differ from vanilla. `mob_ai` timed out while a LAN check ran beside it. Run again alone, its vanilla oracle ran out of heap (`java.lang.OutOfMemoryError: Java heap space` under `-Xmx4g`), before any comparison with Horizon. That side is plain vanilla, so it's this machine, not this branch; please let CI's parity run decide that one. **pr_ready** (`tools/pr_ready.py --base upstream/main` on cachyos, against upstream/main at 795490271, 66 min 26 s) | Check | Result | | --- | --- | | Scope | ✅ 6 files, +54 −5 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ✅ 398 passed (19 s) | | rustfmt | ✅ (4 s) | | clippy | ✅ (1 min 20 s) | | tests: horizon-client | ✅ 1257 passed (2 min 6 s) | | doc tests | ✅ 0 passed (21 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 | ❌ 61 affected, 58 passed, failed: entity_model, mob_ai (62 min 9 s) | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The whole branch (with the `sleep-villager` check and `own_body`): **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on cachyos, against upstream/main at 795490271, 1 min 31 s) | Check | Result | | --- | --- | | Scope | ✅ 8 files, +112 −8 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ✅ 398 passed (19 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ | | tests: horizon-client | ✅ 1257 passed (59 s) | | doc tests | ✅ 0 passed (1 s) | | Parity | ➖ 57 affected, to run in CI (--quick) | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Label: none (a fix). This fork can't set labels upstream. ## Screenshots Before: in the report, the player is missing from the third-person view in bed and the villager lies past the bed. <img width="2000" height="1125" alt="image" src="https://github.com/user-attachments/assets/5a831a23-187e-4e0a-851e-3073bc332ce3" /> <img width="2000" height="1125" alt="image" src="https://github.com/user-attachments/assets/9d631177-6c0f-4492-a0a0-8ac6ce6e4936" /> After: the villager lies on the pillow, and in third person the player lies in the bed with the woken villager beside it <img width="1280" height="720" alt="image" src="https://github.com/user-attachments/assets/6ebdba07-840e-4ddc-bee6-da485d0505a8" /> <img width="1280" height="720" alt="image" src="https://github.com/user-attachments/assets/463e7576-c760-4ddd-ad66-dbc7fa039974" /> 🤖 Generated by an AI agent. Edited by ASOwnerYT. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:07:42 +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#4757
No description provided.