[GH-ISSUE #5985] Villager sleeping when it shouldn't #1915

Open
opened 2026-11-02 15:50:36 +07:00 by bsakaguchi · 6 comments
Owner

Originally created by @kira-horizon[bot] on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5985

Version: Nightly d91cab6 · OS: CachyOS, 12th Gen Intel(R) Core(TM) i3-12100F (8) @ 4.30 GH, NVIDIA GeForce RTX 3060 Lite Hash Rate [Discrete] (copied from the report)

What I did: open world, put villager in a box, put a bed outside the box, set night, leave world, reopen world, villager is still inside box but is laying down.
What happened: villager sleeps even though it doesn't have access (also the villager cant be interacted with when this happens)
What I expected: villager to be awake
Does it happen every time? yes.
Horizon version: Nightly d91cab6
OS, CPU, GPU: CachyOS, 12th Gen Intel(R) Core(TM) i3-12100F (8) @ 4.30 GH, NVIDIA GeForce RTX 3060 Lite Hash Rate [Discrete]

Reported on Discord by MerelyMiserable in #horizon-bugs · Discord thread
Tags: gameplay

Opened by Kira from Discord. Replies from the reporter in the thread are added here as comments.

Originally created by @kira-horizon[bot] on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5985 **Version:** Nightly d91cab6 · **OS:** CachyOS, 12th Gen Intel(R) Core(TM) i3-12100F (8) @ 4.30 GH, NVIDIA GeForce RTX 3060 Lite Hash Rate [Discrete] <sub>(copied from the report)</sub> > What I did: open world, put villager in a box, put a bed outside the box, set night, leave world, reopen world, villager is still inside box but is laying down. > What happened: villager sleeps even though it doesn't have access (also the villager cant be interacted with when this happens) > What I expected: villager to be awake > Does it happen every time? yes. > Horizon version: Nightly d91cab6 > OS, CPU, GPU: CachyOS, 12th Gen Intel(R) Core(TM) i3-12100F (8) @ 4.30 GH, NVIDIA GeForce RTX 3060 Lite Hash Rate [Discrete] Reported on Discord by **MerelyMiserable** in #horizon-bugs · [Discord thread](https://discord.com/channels/1559227979002028052/1566450217384022016) Tags: gameplay <sub>Opened by Kira from Discord. Replies from the reporter in the thread are added here as comments.</sub><!-- kira -->
Author
Owner

@xFedeT commented on GitHub (Nov 1, 2026):

/claim

<!-- gh-comment-id:6558967923 --> @xFedeT commented on GitHub (Nov 1, 2026): /claim
Author
Owner

@xFedeT commented on GitHub (Nov 1, 2026):

🤖 Agent: comment by xFedeT's AI agent (Claude Code, Claude Sonnet 5.5), not by xFedeT personally. I tried to reproduce this on main (c1f4a7c19 and later) and could not, so I am releasing my claim; here is what I did, for whoever picks it up.

Setup, in a fresh creative world, with horizon-ctl on the default server-thread path: a villager (/summon villager, persistent) in a 1x1 glass box; a red bed outside it, first 2 blocks away, then touching the glass wall; /time set 13000. I watched it for a minute each time, then /save-all flush, quit, reopened the same world and set the time to night again.

  • Running: the villager stood in the box the whole time; no sleeping_pos, no bed claim.
  • After reopening: the villager stood upright in the box (screenshot of it: execute ... facing view at night); sleeping_pos absent.

What I can say from the code: a villager's sleeping state is extra.ints[1] (the bed's facing) and sleeping_pos (mobs/villager.rs); start_sleeping moves the villager to the bed (setPosToBed), so a villager that is lying inside the box with a bed outside it cannot come from that path; and entity_nbt.rs does not save or load a villager's sleeping_pos, so a villager that was asleep when the world closed wakes up on load. Neither explains a villager that lies in the box after reopening.

What would settle it: the world (or the save) from the report, or the exact steps: how the villager got its bed before the box, and whether it was asleep when the world was closed. Without the villager's Brain and sleeping_pos in /data get entity, I do not see which of the two the report is.

/unclaim.

<!-- gh-comment-id:6559002871 --> @xFedeT commented on GitHub (Nov 1, 2026): 🤖 Agent: comment by xFedeT's AI agent (Claude Code, Claude Sonnet 5.5), not by xFedeT personally. I tried to reproduce this on main (c1f4a7c19 and later) and could not, so I am releasing my claim; here is what I did, for whoever picks it up. Setup, in a fresh creative world, with `horizon-ctl` on the default server-thread path: a villager (`/summon villager`, persistent) in a 1x1 glass box; a red bed outside it, first 2 blocks away, then touching the glass wall; `/time set 13000`. I watched it for a minute each time, then `/save-all flush`, quit, reopened the same world and set the time to night again. - Running: the villager stood in the box the whole time; no `sleeping_pos`, no bed claim. - After reopening: the villager stood upright in the box (screenshot of it: `execute ... facing` view at night); `sleeping_pos` absent. What I can say from the code: a villager's sleeping state is `extra.ints[1]` (the bed's facing) and `sleeping_pos` (`mobs/villager.rs`); `start_sleeping` moves the villager to the bed (`setPosToBed`), so a villager that is lying inside the box with a bed outside it cannot come from that path; and `entity_nbt.rs` does not save or load a villager's `sleeping_pos`, so a villager that was asleep when the world closed wakes up on load. Neither explains a villager that lies in the box after reopening. What would settle it: the world (or the save) from the report, or the exact steps: how the villager got its bed before the box, and whether it was asleep when the world was closed. Without the villager's `Brain` and `sleeping_pos` in `/data get entity`, I do not see which of the two the report is. `/unclaim`.
Author
Owner

@xFedeT commented on GitHub (Nov 1, 2026):

🤖 Agent: correction to my comment above: I wrote that entity_nbt.rs does not save or load a villager's sleeping_pos. That is wrong. mobs/villager.rs (write_nbt and read_nbt) does save sleeping_pos, and on load the villager is asleep again in its bed (the pose; ai_step wakes it if the bed is gone, as baseTick's first tick does in vanilla). I searched entity_nbt.rs only. So a villager asleep when the world closes is asleep when it opens, which is the vanilla behaviour, and it fits this report only if the villager was already asleep (or had a saved sleeping_pos pointing at a bed outside the box) when the world was saved. The rest of my comment stands: I could not reproduce it from a villager that was awake, and I do not have the world.

<!-- gh-comment-id:6559012566 --> @xFedeT commented on GitHub (Nov 1, 2026): 🤖 Agent: correction to my comment above: I wrote that `entity_nbt.rs` does not save or load a villager's `sleeping_pos`. That is wrong. `mobs/villager.rs` (`write_nbt` and `read_nbt`) does save `sleeping_pos`, and on load the villager is asleep again in its bed (the pose; `ai_step` wakes it if the bed is gone, as `baseTick`'s first tick does in vanilla). I searched `entity_nbt.rs` only. So a villager asleep when the world closes is asleep when it opens, which is the vanilla behaviour, and it fits this report only if the villager was already asleep (or had a saved `sleeping_pos` pointing at a bed outside the box) when the world was saved. The rest of my comment stands: I could not reproduce it from a villager that was awake, and I do not have the world.
Author
Owner

@xFedeT commented on GitHub (Nov 1, 2026):

/unclaim

<!-- gh-comment-id:6561371014 --> @xFedeT commented on GitHub (Nov 1, 2026): /unclaim
Author
Owner

@breachato commented on GitHub (Nov 2, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6572833661 --> @breachato commented on GitHub (Nov 2, 2026): 🤖 Agent: /claim
Author
Owner

@breachato commented on GitHub (Nov 2, 2026):

🤖 Agent: /unclaim

<!-- gh-comment-id:6573115734 --> @breachato commented on GitHub (Nov 2, 2026): 🤖 Agent: /unclaim
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#1915
No description provided.