[PR #725] [MERGED] Guests: a bed puts the guest to sleep, not the host #2759

Closed
opened 2026-11-02 15:58:49 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/725
Author: @ludovic111
Created: 10/17/2026
Status: ✅ Merged
Merged: 10/18/2026
Merged by: @ludovic111

Base: main ← Head: fix/guest-sleeping


📝 Commits (1)

  • 28d218b Guests: a bed puts the guest to sleep, not the host

📊 Changes

9 files changed (+273 additions, -27 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+30 -22)
📝 crates/horizon-client/src/game/agent.rs (+2 -0)
📝 crates/horizon-client/src/game/lan.rs (+1 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+105 -1)
📝 crates/horizon-client/src/game/remote.rs (+33 -1)
📝 crates/horizon-client/src/lan/guest.rs (+12 -0)
📝 crates/horizon-client/src/lan/hub.rs (+36 -1)
📝 crates/horizon-client/src/lan/playerdata.rs (+2 -0)
📝 tools/lan_e2e.py (+52 -2)

📄 Description

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

Fixes #696 (part): Sleeping, when a guest clicks a bed, the host goes to sleep instead.

Cause

A guest's bed click runs on the host's Game through as_guest. The bed's sleeping state, sleep timer and respawn point were the host's own fields, and as_guest didn't swap them. So try_sleep put the host in bed and moved the host's spawn.

Fix

  • as_guest swaps the sleeping bed, the sleep timer and the respawn point with the guest's own. It keeps the host's respawn_config and level spawn, and sends the guest its own action-bar message (for example "You can only sleep at night").
  • The guest lies down in the bed. Like LivingEntity.startSleeping, it gets its SLEEPING pose (entity data 6) and its sleeping position (entity data 14). On STOP_SLEEPING it wakes with the WAKE_UP animation (ClientboundAnimatePacket action 0), and it wakes when it dies or the bed is gone.
  • The night skips only once enough players sleep: SleepStatus, players_sleeping_percentage, max(1, ceil(active × pct / 100)). Then everyone wakes.
  • Guests respawn at their own bed, else the world spawn, never the host's bed. The guest's spawn is saved in its player data.
  • Server clients place themselves in the bed from the synced position, stay still while asleep, and leave the bed with Escape (PlayerCommand STOP_SLEEPING).

Tests

New lan_e2e.py --check sleep:

  • At midnight the guest lies down in its own bed, as seen by both the guest and the server; the host stays up.
  • With only one of the two players asleep, it is still night 120 ticks later.
  • Escape gets the guest up.
  • Once both sleep, it is morning and both are awake.

Before: FAIL. After: PASS.

Self-check

These ran on one integration commit holding the six #696 branches (#722 to #727), plus a per-branch check:

  • cargo fmt --all --check: ok on each branch.
  • cargo clippy --workspace --all-targets -- -D warnings: ok on the integration commit. cargo clippy -p horizon-client --all-targets -- -D warnings: ok on this branch alone.
  • cargo test -p horizon-client --lib: 823 passed, 0 failed, 11 ignored (integration commit).
  • tools/lan_e2e.py on the integration commit: tab, self, armour, nametags, walls, chest, crafting, damage, mobs, pvp, containers, feedback, trials, clicks, xp, sleep, push and eat all PASS.
    • hazards passes, but it leaves the guest dying in the void, so every check after it fails on the dead screen. The same happens on main, so it was run on its own.
  • Local parity (PARITY_LOCAL_JOBS=3 tools/parity.py --changed origin/main, 88 harnesses): 88 passed, 0 failed (137 min).

Overlaps

  • The open PRs #695, #697 and #700 also touch game/lan_actions.rs, lan/hub.rs, lan/guest.rs, lan/playerdata.rs and tools/lan_e2e.py; #708 touches game/remote.rs and tools/lan_e2e.py.
  • The six #696 PRs each add a check to tools/lan_e2e.py's CHECKS list, and some share game/remote.rs. Whichever merges second needs a small rebase.
  • The recipe book from #696 is #714 (perf-ticks-5), not here.

🤖 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/725 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/18/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/guest-sleeping` --- ### 📝 Commits (1) - [`28d218b`](https://github.com/horizon-rust/horizon/commit/28d218b3a2c17ff1b5b373b52b24b8d3000bfd2e) Guests: a bed puts the guest to sleep, not the host ### 📊 Changes **9 files changed** (+273 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+30 -22) 📝 `crates/horizon-client/src/game/agent.rs` (+2 -0) 📝 `crates/horizon-client/src/game/lan.rs` (+1 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+105 -1) 📝 `crates/horizon-client/src/game/remote.rs` (+33 -1) 📝 `crates/horizon-client/src/lan/guest.rs` (+12 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+36 -1) 📝 `crates/horizon-client/src/lan/playerdata.rs` (+2 -0) 📝 `tools/lan_e2e.py` (+52 -2) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes #696 (part): **Sleeping**, when a guest clicks a bed, the host goes to sleep instead. ## Cause A guest's bed click runs on the host's `Game` through `as_guest`. The bed's sleeping state, sleep timer and respawn point were the host's own fields, and `as_guest` didn't swap them. So `try_sleep` put the host in bed and moved the host's spawn. ## Fix - `as_guest` swaps the sleeping bed, the sleep timer and the respawn point with the guest's own. It keeps the host's `respawn_config` and level spawn, and sends the guest its own action-bar message (for example "You can only sleep at night"). - The guest lies down in the bed. Like `LivingEntity.startSleeping`, it gets its `SLEEPING` pose (entity data 6) and its sleeping position (entity data 14). On `STOP_SLEEPING` it wakes with the `WAKE_UP` animation (`ClientboundAnimatePacket` action 0), and it wakes when it dies or the bed is gone. - The night skips only once enough players sleep: `SleepStatus`, `players_sleeping_percentage`, `max(1, ceil(active × pct / 100))`. Then everyone wakes. - Guests respawn at their own bed, else the world spawn, never the host's bed. The guest's spawn is saved in its player data. - Server clients place themselves in the bed from the synced position, stay still while asleep, and leave the bed with Escape (`PlayerCommand` STOP_SLEEPING). ## Tests New `lan_e2e.py --check sleep`: - At midnight the guest lies down in its own bed, as seen by both the guest and the server; the host stays up. - With only one of the two players asleep, it is still night 120 ticks later. - Escape gets the guest up. - Once both sleep, it is morning and both are awake. Before: FAIL. After: PASS. ## Self-check These ran on one integration commit holding the six #696 branches (#722 to #727), plus a per-branch check: - `cargo fmt --all --check`: ok on each branch. - `cargo clippy --workspace --all-targets -- -D warnings`: ok on the integration commit. `cargo clippy -p horizon-client --all-targets -- -D warnings`: ok on this branch alone. - `cargo test -p horizon-client --lib`: 823 passed, 0 failed, 11 ignored (integration commit). - `tools/lan_e2e.py` on the integration commit: tab, self, armour, nametags, walls, chest, crafting, damage, mobs, pvp, containers, feedback, trials, clicks, xp, sleep, push and eat all PASS. - `hazards` passes, but it leaves the guest dying in the void, so every check after it fails on the dead screen. The same happens on main, so it was run on its own. - Local parity (`PARITY_LOCAL_JOBS=3 tools/parity.py --changed origin/main`, 88 harnesses): 88 passed, 0 failed (137 min). ## Overlaps - The open PRs #695, #697 and #700 also touch `game/lan_actions.rs`, `lan/hub.rs`, `lan/guest.rs`, `lan/playerdata.rs` and `tools/lan_e2e.py`; #708 touches `game/remote.rs` and `tools/lan_e2e.py`. - The six #696 PRs each add a check to `tools/lan_e2e.py`'s `CHECKS` list, and some share `game/remote.rs`. Whichever merges second needs a small rebase. - The recipe book from #696 is #714 (perf-ticks-5), not here. 🤖 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-02 15:58:49 +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#2759
No description provided.