[PR #2150] [MERGED] Villagers find a child's bed in the full 48 block sphere and only take reachable ones #4052

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

📋 Pull Request Information

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

Base: main ← Head: fix/villager-bed-search-radius


📝 Commits (1)

  • 688d86d Villagers look for a child's bed in a full 48 block sphere and only take one they can reach

📊 Changes

2 files changed (+18 additions, -30 deletions)

View changed files

📝 crates/horizon-client/src/mobs/villager.rs (+0 -24)
📝 crates/horizon-client/src/mobs/villager_brain.rs (+18 -6)

📄 Description

What and why

When two villagers make a baby, the parent looks for a free bed for the child. Horizon only looked 8 blocks up and down from the parent, so a free bed on another floor or hill of a village was never found and breeding failed with the angry-villager particles. It also gave away any bed in range without checking that the villager can walk to it, so a bed behind a wall or on an island could be assigned to the baby.

The search now:

  • covers the whole sphere of radius 48, like vanilla, by reading the POI index (homes_in_range) instead of scanning blocks. The old code scanned a 97 x 17 x 97 box block by block; scanning the full sphere that way would have been a 97 x 97 x 97 scan on every birth.
  • tests the free beds nearest first and takes the first one the villager has a path to (create_path_to with the bed's valid range, and the path must reach it).

The checks on the bed itself are unchanged: it must be a bed head, not occupied, and not claimed by another villager. The now unused take_vacant_bed helper is removed.

Vanilla reference

  • VillagerMakeLove.takeVacantBed: PoiManager.take(HOME, ..., body.blockPosition(), 48) with a canReach filter.
  • VillagerMakeLove.canReach: createPath(poiPos, poiType.validRange()), and path != null && path.canReach().
  • PoiManager.getInRange: a square of chunks around the center, then distSqr <= radius * radius, so a full 3D sphere.

Self-check

cargo check -p horizon-client passes.


🔄 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/2150 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/villager-bed-search-radius` --- ### 📝 Commits (1) - [`688d86d`](https://github.com/horizon-rust/horizon/commit/688d86db7cc05196a00e9e91c09741e0e123540c) Villagers look for a child's bed in a full 48 block sphere and only take one they can reach ### 📊 Changes **2 files changed** (+18 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mobs/villager.rs` (+0 -24) 📝 `crates/horizon-client/src/mobs/villager_brain.rs` (+18 -6) </details> ### 📄 Description ## What and why When two villagers make a baby, the parent looks for a free bed for the child. Horizon only looked 8 blocks up and down from the parent, so a free bed on another floor or hill of a village was never found and breeding failed with the angry-villager particles. It also gave away any bed in range without checking that the villager can walk to it, so a bed behind a wall or on an island could be assigned to the baby. The search now: - covers the whole sphere of radius 48, like vanilla, by reading the POI index (`homes_in_range`) instead of scanning blocks. The old code scanned a 97 x 17 x 97 box block by block; scanning the full sphere that way would have been a 97 x 97 x 97 scan on every birth. - tests the free beds nearest first and takes the first one the villager has a path to (`create_path_to` with the bed's valid range, and the path must reach it). The checks on the bed itself are unchanged: it must be a bed head, not occupied, and not claimed by another villager. The now unused `take_vacant_bed` helper is removed. ## Vanilla reference - `VillagerMakeLove.takeVacantBed`: `PoiManager.take(HOME, ..., body.blockPosition(), 48)` with a `canReach` filter. - `VillagerMakeLove.canReach`: `createPath(poiPos, poiType.validRange())`, and `path != null && path.canReach()`. - `PoiManager.getInRange`: a square of chunks around the center, then `distSqr <= radius * radius`, so a full 3D sphere. ## Self-check `cargo check -p horizon-client` passes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:14:19 +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#4052
No description provided.