[PR #1536] [MERGED] Villagers open and close doors on their paths #3566

Closed
opened 2026-11-03 04:10:29 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/dg1-villager-doors


📝 Commits (2)

  • 969bcec Villagers open and close doors on their paths
  • c466c5d Merge remote-tracking branch 'origin/main' into fix/dg1-villager-doors

📊 Changes

6 files changed (+182 additions, -3 deletions)

View changed files

📝 crates/horizon-client/examples/probe/mob_ai_probe.rs (+25 -0)
📝 crates/horizon-client/src/game/creatures.rs (+5 -0)
📝 crates/horizon-client/src/mobs.rs (+6 -0)
📝 crates/horizon-client/src/mobs/villager_brain.rs (+69 -1)
📝 crates/horizon-world/src/level/interact.rs (+27 -0)
📝 tools/lan_e2e.py (+50 -2)

📄 Description

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

What players saw

On Discord: "every villager you go to, they are not specialized by default". In generated villages, jobless villagers stayed jobless.

Measured against vanilla

Both on a dedicated server, seed 12345. The plains village at about (-144, -832) has 5 villagers (2 nitwits, 3 jobless), the chunks are force-loaded, and the time is day.

server after 6 to 7 minutes
vanilla 26.3 all 3 jobless villagers took a job: 2 farmers (composters at -160 64 -835 and -170 64 -835) and 1 mason (stonecutter at -143 78 -814), the first after 25 s
Horizon main none. Two villagers stood still inside closed oak door blocks: (-160, 65, -821) and (-146, 79, -804)
this branch 1 farmer (composter -160 64 -835), the first round

Controls on Horizon main:

  • a villager summoned next to a placed composter became a farmer;
  • a village villager teleported onto an open platform took a stonecutter within 5 s.

So AcquirePoi and AssignProfessionFromJobSite work; doors are what stopped the village villagers.

Cause

interact_with_doors (InteractWithDoor) was a stub (let _ = (m, cx, from, to);) from the villager brain port onwards. A path through a closed door is valid for villagers (canOpenDoors), so they walked into the door and stayed there, and never reached a job site, a bed or the meeting point.

Fix

This follows vanilla InteractWithDoor:

  • Opens a closed door in MOB_INTERACTABLE_DOORS on the from or to node of the path step, through DoorBlock.setOpen: both halves, setBlock flags 10, the door sound and the block_open / block_close game event. This is the new Behaviours::set_door_open, applied from the new MobEvent::SetDoorOpen.
  • Remembers the from door always, and the to door only when this villager opened it (DOORS_TO_CLOSE).
  • closeDoorsThatIHaveOpenedOrPassedThrough: skips the step's two nodes and forgets every other door. A door is closed only if it is still open, within 3 blocks, and no other villager within 2 blocks has its path's previous or next node on it.
  • SleepInBed closes them too when the villager lies down.
  • The mob AI probe applies the event, so the mob_ai harness sees the doors as the game does.

Known differences, not fixed here:

  • Mob events apply after the mob loop, so the door opens one tick after vanilla's, where setOpen changes the world during the brain tick. A strict per-tick mob_ai scenario with a door is one tick behind for that reason, so it is not part of this PR.
  • ServerLevel.sendBlockUpdated doesn't make nearby mobs recompute their paths in Horizon.

Check

tools/lan_e2e.py --check doors shuts a villager in a plank room with a closed oak door and puts a free composter 5 blocks outside it:

  • the guest must see the door open;
  • the villager must become a farmer (an execute if entity …nbt={VillagerData:{profession:"minecraft:farmer"}} marker block);
  • the door must end up closed on the server and on the guest.
binary doors
main FAIL: the villager never opened its door
this branch PASS, in single player and --server-thread

The village gap isn't closed yet: vanilla had 3 of 3 employed, this branch 1 of 3. The other two jobless villagers kept their home and meeting point and wandered east of the village (x ≈ -106 to -125), and never acquired the stonecutter or the second composter. A fresh villager summoned beside either of them took it within 30 s. In one of the two runs on this branch, the farmer also lost its job site after about two minutes and went back to none. That needs its own investigation (village-bound strolling or path reach). This PR does not claim it.

Self-check

  • cargo fmt --all -- --check: clean
  • cargo clippy --workspace --all-targets -- -D warnings: clean
  • cargo test -p horizon-world -p horizon-client: pass
  • tools/parity.py --changed origin/main: 200 of the 310 affected harnesses passed, 0 failed: mob_ai, use_item_on, block_update, interaction_input and interaction_shape among them. The run stopped at the agent's 2-hour limit, so the other 110 have not run on this branch yet

🤖 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/1536 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/24/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/dg1-villager-doors` --- ### 📝 Commits (2) - [`969bcec`](https://github.com/horizon-rust/horizon/commit/969bcec6c9d3a3bde1c37efe269c9c0d20cba721) Villagers open and close doors on their paths - [`c466c5d`](https://github.com/horizon-rust/horizon/commit/c466c5ddad9be0ea7b91d0022b602a257076dabf) Merge remote-tracking branch 'origin/main' into fix/dg1-villager-doors ### 📊 Changes **6 files changed** (+182 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/probe/mob_ai_probe.rs` (+25 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+5 -0) 📝 `crates/horizon-client/src/mobs.rs` (+6 -0) 📝 `crates/horizon-client/src/mobs/villager_brain.rs` (+69 -1) 📝 `crates/horizon-world/src/level/interact.rs` (+27 -0) 📝 `tools/lan_e2e.py` (+50 -2) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What players saw On Discord: "every villager you go to, they are not specialized by default". In generated villages, jobless villagers stayed jobless. ## Measured against vanilla Both on a dedicated server, seed 12345. The plains village at about (-144, -832) has 5 villagers (2 nitwits, 3 jobless), the chunks are force-loaded, and the time is day. | server | after 6 to 7 minutes | | --- | --- | | vanilla 26.3 | all 3 jobless villagers took a job: 2 farmers (composters at -160 64 -835 and -170 64 -835) and 1 mason (stonecutter at -143 78 -814), the first after 25 s | | Horizon main | none. Two villagers stood still inside closed oak door blocks: (-160, 65, -821) and (-146, 79, -804) | | this branch | 1 farmer (composter -160 64 -835), the first round | Controls on Horizon main: - a villager summoned next to a placed composter became a farmer; - a village villager teleported onto an open platform took a stonecutter within 5 s. So AcquirePoi and AssignProfessionFromJobSite work; doors are what stopped the village villagers. ## Cause `interact_with_doors` (`InteractWithDoor`) was a stub (`let _ = (m, cx, from, to);`) from the villager brain port onwards. A path through a closed door is valid for villagers (`canOpenDoors`), so they walked into the door and stayed there, and never reached a job site, a bed or the meeting point. ## Fix This follows vanilla `InteractWithDoor`: - Opens a closed door in `MOB_INTERACTABLE_DOORS` on the from or to node of the path step, through `DoorBlock.setOpen`: both halves, setBlock flags 10, the door sound and the `block_open` / `block_close` game event. This is the new `Behaviours::set_door_open`, applied from the new `MobEvent::SetDoorOpen`. - Remembers the from door always, and the to door only when this villager opened it (`DOORS_TO_CLOSE`). - `closeDoorsThatIHaveOpenedOrPassedThrough`: skips the step's two nodes and forgets every other door. A door is closed only if it is still open, within 3 blocks, and no other villager within 2 blocks has its path's previous or next node on it. - `SleepInBed` closes them too when the villager lies down. - The mob AI probe applies the event, so the mob_ai harness sees the doors as the game does. Known differences, not fixed here: - Mob events apply after the mob loop, so the door opens one tick after vanilla's, where `setOpen` changes the world during the brain tick. A strict per-tick mob_ai scenario with a door is one tick behind for that reason, so it is not part of this PR. - `ServerLevel.sendBlockUpdated` doesn't make nearby mobs recompute their paths in Horizon. ## Check `tools/lan_e2e.py --check doors` shuts a villager in a plank room with a closed oak door and puts a free composter 5 blocks outside it: - the guest must see the door open; - the villager must become a farmer (an `execute if entity …nbt={VillagerData:{profession:"minecraft:farmer"}}` marker block); - the door must end up closed on the server and on the guest. | binary | doors | | --- | --- | | main | FAIL: `the villager never opened its door` | | this branch | PASS, in single player and `--server-thread` | The village gap isn't closed yet: vanilla had 3 of 3 employed, this branch 1 of 3. The other two jobless villagers kept their home and meeting point and wandered east of the village (x ≈ -106 to -125), and never acquired the stonecutter or the second composter. A fresh villager summoned beside either of them took it within 30 s. In one of the two runs on this branch, the farmer also lost its job site after about two minutes and went back to none. That needs its own investigation (village-bound strolling or path reach). This PR does not claim it. ## Self-check - `cargo fmt --all -- --check`: clean - `cargo clippy --workspace --all-targets -- -D warnings`: clean - `cargo test -p horizon-world -p horizon-client`: pass - `tools/parity.py --changed origin/main`: 200 of the 310 affected harnesses passed, 0 failed: mob_ai, use_item_on, block_update, interaction_input and interaction_shape among them. The run stopped at the agent's 2-hour limit, so the other 110 have not run on this branch yet 🤖 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 04:10:29 +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#3566
No description provided.