[PR #6505] [CLOSED] Let farmer villagers work mod crops, soil and seeds #6920

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6505
Author: @navinor
Created: 11/1/2026
Status: ❌ Closed

Base: main ← Head: feat/villager-mod-farming


📝 Commits (2)

  • b77c973 Let farmers work a mod's farmland, crops and seeds
  • 569323f Keep villager bonemealing limited to vanilla crops

📊 Changes

5 files changed (+339 additions, -49 deletions)

View changed files

📝 crates/horizon-client/src/game/villagers.rs (+1 -2)
📝 crates/horizon-client/src/mobs/villager.rs (+25 -17)
📝 crates/horizon-client/src/mobs/villager_brain.rs (+287 -28)
📝 crates/horizon-client/src/mobs/world.rs (+16 -2)
📝 docs/native-mods.md (+10 -0)

📄 Description

🤖 Opened by navinor's AI agent (OpenCode, Claude Opus 5.5 and GPT-6.1 Sol), not by navinor personally.

What and why

Fixes #5533. Farmer villagers worked only minecraft:farmland and vanilla's five crops, matched by name, and sowed only vanilla's six seeds from a table. A mod's farmland, crops and seeds were ignored.

Vanilla's HarvestFarmland doesn't check names. A crop is instanceof CropBlock, ripe at isMaxAge (getMaxAge: 7, BeetrootBlock 3, TorchflowerCropBlock 2, which its age 0-1 never reaches). The soil is instanceof FarmlandBlock. The seed is the first inventory stack in villager_plantable_seeds that is a BlockItem, planted as its block's default state. A content block takes its template's class chain, so Horizon now checks the same things:

  • villager::crop and ripe_crop read the class chain and the age instead of a name list.
  • villager::farmland is a FarmlandBlock. The secondary job site sensor, validPos and planting all use it. Vanilla's SecondaryPoiSensor names minecraft:farmland; matching the class there lets a farm made only of a mod's farmland be worked. No vanilla block other than farmland has that class.
  • Planting takes the first stack in minecraft:villager_plantable_seeds that places a block (ItemInfo.block) and sets that state with MobEvent::SetBlock (UPDATE_ALL, as before). The six-seed table is gone.
  • Villager item sensing and pickup read the world's tags (Game::items), as planting already did, so seeds a data pack or a native mod (native_data_pack_files) adds to the tag reach the inventory.

No new hook: a native mod's blocks are content blocks with templates. docs/native-mods.md gains a "Farmer villagers" section on making a crop and soil farmers work, including minecraft:supports_crops (26.3's CropBlock.mayPlaceOn).

Villager bone meal (UseBonemeal) keeps its existing vanilla-only targets; mod crop bonemealing is outside this change.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

HarvestFarmland.checkExtraStartConditions, validPos and tick; SecondaryPoiSensor.doTick; Villager.hasFarmSeeds and wantsToPickUp; CropBlock.isMaxAge, getMaxAge and mayPlaceOn; BeetrootBlock.getMaxAge; TorchflowerCropBlock.getMaxAge; UseBonemeal.validPos.

Tests: mobs::villager_brain::farming_tests (4 new). The farming tests load prepared vanilla data and give farmland, crops and seeds mod names: templated wheat ripens at 7, beetroot at 3, torchflower crop never; a farmer senses mod farmland but not dirt; it harvests a ripe mod crop and sows the first tagged block-item seed, skipping an untagged block item and a tagged stick. These three failed before the farming fix. The fourth test caught the accidental bonemeal scope expansion, failed with a mod crop selected, then passed after restoring vanilla-only targets. cargo test -p horizon-client-lib --lib villager: 25 passed, 1 ignored. Harness: mob_ai covers villagers; not run locally.

Other projects' code

None copied. While researching, the agent read NeoForge's (LGPL-2.1) patches/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch, patches/net/minecraft/world/entity/npc/villager/Villager.java.patch and parts of Tags.java and SpecialPlantable.java on its 1.21.x branch, before checking CONTRIBUTING. The neoforge:villager_farmlands tag those files suggested was dropped for that reason; everything here follows vanilla 26.3's classes above.

Self-check

Latest full self-check on b77c973bd, before the isolated bonemeal correction:

pr_ready (tools/pr_ready.py --quick --base f4833621f on Aaron, against f4833621f at f4833621f, 7 min 34 s)

Check Result
Scope ✅ 6 files, +278 −47
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 594 passed (2 min 14 s)
rustfmt ✅ (19 s)
clippy ✅ (2 min 1 s)
tests: horizon-client, horizon-client-lib ❌ 580 passed, 2 failed (2 min 50 s)
doc tests ✅ 0 passed (7 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 ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The scope row counted the untracked local .codegraph/.gitignore. The final reviewed source diff is 5 files, +339 −49. After the bonemeal correction, a fresh independent QA run passed all 25 villager tests (1 existing ignored), targeted rustfmt and scoped git diff --check. No full readiness or parity run was repeated after that correction.

The two current self-check failures, native_breathing_stays_hookable and native_loot_kinds_stay_hookable, reproduce with identical Option::unwrap() panics on unchanged f4833621f and this branch. Those hooks are untouched. The earlier input-capture and armor-stand failures no longer occur on this base.

Screenshots

Same content-mod scene on the default integrated server thread: rice copied from wheat, rich farmland copied from farmland, and loam copied from dirt. A world data pack adds the rice item to minecraft:villager_plantable_seeds. The farmer starts with one seed; random crop growth is disabled.

On unchanged dea6dea98, the farmer harvested nothing in 187 seconds and retained its one seed:

Baseline: mod crops remain unharvested

On rebased b77c973bd, the server-thread run harvested all eight ripe crops on the mod farmland (right) and ended with nine replanted cells, one empty cell, and one seed left. The loam control (left) was not resown. The screenshot does not establish why the one farmland cell became empty:

Fixed: mod farmland harvested and replanted

The dedicated server (--dedicated --nogui, same mod and data pack) independently harvested all eight ripe farmland crops and ended with nine replanted cells, one empty cell, and one seed left. An earlier fixed integrated-server run reached 10/10 planted cells at 88 seconds. These live scenes used no bone meal; the final bonemeal-only correction is covered by the target-selection regression and independent QA above. Both attached images were downloaded anonymously and matched the original PNG SHA-256 hashes byte-for-byte.

Reviewed with sol-loop: 3 rounds with GPT-6.1 Sol on xhigh. Sol verdict: approved

🤖 Generated with OpenCode, Claude Opus 5.5 and GPT-6.1 Sol.


🔄 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/6505 **Author:** [@navinor](https://github.com/navinor) **Created:** 11/1/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/villager-mod-farming` --- ### 📝 Commits (2) - [`b77c973`](https://github.com/horizon-rust/horizon/commit/b77c973bd95946cd3d82f4a546e4d9525001d0bc) Let farmers work a mod's farmland, crops and seeds - [`569323f`](https://github.com/horizon-rust/horizon/commit/569323ff479ccf66045dca260678113dadd14050) Keep villager bonemealing limited to vanilla crops ### 📊 Changes **5 files changed** (+339 additions, -49 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/villagers.rs` (+1 -2) 📝 `crates/horizon-client/src/mobs/villager.rs` (+25 -17) 📝 `crates/horizon-client/src/mobs/villager_brain.rs` (+287 -28) 📝 `crates/horizon-client/src/mobs/world.rs` (+16 -2) 📝 `docs/native-mods.md` (+10 -0) </details> ### 📄 Description > 🤖 Opened by navinor's AI agent (OpenCode, Claude Opus 5.5 and GPT-6.1 Sol), not by navinor personally. ## What and why Fixes #5533. Farmer villagers worked only `minecraft:farmland` and vanilla's five crops, matched by name, and sowed only vanilla's six seeds from a table. A mod's farmland, crops and seeds were ignored. Vanilla's `HarvestFarmland` doesn't check names. A crop is `instanceof CropBlock`, ripe at `isMaxAge` (`getMaxAge`: 7, `BeetrootBlock` 3, `TorchflowerCropBlock` 2, which its age 0-1 never reaches). The soil is `instanceof FarmlandBlock`. The seed is the first inventory stack in `villager_plantable_seeds` that is a `BlockItem`, planted as its block's default state. A content block takes its template's class chain, so Horizon now checks the same things: - `villager::crop` and `ripe_crop` read the class chain and the age instead of a name list. - `villager::farmland` is a `FarmlandBlock`. The secondary job site sensor, `validPos` and planting all use it. Vanilla's `SecondaryPoiSensor` names `minecraft:farmland`; matching the class there lets a farm made only of a mod's farmland be worked. No vanilla block other than farmland has that class. - Planting takes the first stack in `minecraft:villager_plantable_seeds` that places a block (`ItemInfo.block`) and sets that state with `MobEvent::SetBlock` (`UPDATE_ALL`, as before). The six-seed table is gone. - Villager item sensing and pickup read the world's tags (`Game::items`), as planting already did, so seeds a data pack or a native mod (`native_data_pack_files`) adds to the tag reach the inventory. No new hook: a native mod's blocks are content blocks with templates. `docs/native-mods.md` gains a "Farmer villagers" section on making a crop and soil farmers work, including `minecraft:supports_crops` (26.3's `CropBlock.mayPlaceOn`). Villager bone meal (`UseBonemeal`) keeps its existing vanilla-only targets; mod crop bonemealing is outside this change. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [x] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference `HarvestFarmland.checkExtraStartConditions`, `validPos` and `tick`; `SecondaryPoiSensor.doTick`; `Villager.hasFarmSeeds` and `wantsToPickUp`; `CropBlock.isMaxAge`, `getMaxAge` and `mayPlaceOn`; `BeetrootBlock.getMaxAge`; `TorchflowerCropBlock.getMaxAge`; `UseBonemeal.validPos`. Tests: `mobs::villager_brain::farming_tests` (4 new). The farming tests load prepared vanilla data and give farmland, crops and seeds mod names: templated wheat ripens at 7, beetroot at 3, torchflower crop never; a farmer senses mod farmland but not dirt; it harvests a ripe mod crop and sows the first tagged block-item seed, skipping an untagged block item and a tagged stick. These three failed before the farming fix. The fourth test caught the accidental bonemeal scope expansion, failed with a mod crop selected, then passed after restoring vanilla-only targets. `cargo test -p horizon-client-lib --lib villager`: 25 passed, 1 ignored. Harness: `mob_ai` covers villagers; not run locally. ## Other projects' code None copied. While researching, the agent read NeoForge's (LGPL-2.1) `patches/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch`, `patches/net/minecraft/world/entity/npc/villager/Villager.java.patch` and parts of `Tags.java` and `SpecialPlantable.java` on its `1.21.x` branch, before checking CONTRIBUTING. The `neoforge:villager_farmlands` tag those files suggested was dropped for that reason; everything here follows vanilla 26.3's classes above. ## Self-check Latest full self-check on `b77c973bd`, before the isolated bonemeal correction: **pr_ready** (`tools/pr_ready.py --quick --base f4833621f` on Aaron, against f4833621f at f4833621f, 7 min 34 s) | Check | Result | | --- | --- | | Scope | ✅ 6 files, +278 −47 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 594 passed (2 min 14 s) | | rustfmt | ✅ (19 s) | | clippy | ✅ (2 min 1 s) | | tests: horizon-client, horizon-client-lib | ❌ 580 passed, 2 failed (2 min 50 s) | | doc tests | ✅ 0 passed (7 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 | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The scope row counted the untracked local `.codegraph/.gitignore`. The final reviewed source diff is 5 files, +339 −49. After the bonemeal correction, a fresh independent QA run passed all 25 villager tests (1 existing ignored), targeted rustfmt and scoped `git diff --check`. No full readiness or parity run was repeated after that correction. The two current self-check failures, `native_breathing_stays_hookable` and `native_loot_kinds_stay_hookable`, reproduce with identical `Option::unwrap()` panics on unchanged `f4833621f` and this branch. Those hooks are untouched. The earlier input-capture and armor-stand failures no longer occur on this base. ## Screenshots Same content-mod scene on the default integrated server thread: rice copied from wheat, rich farmland copied from farmland, and loam copied from dirt. A world data pack adds the rice item to `minecraft:villager_plantable_seeds`. The farmer starts with one seed; random crop growth is disabled. On unchanged `dea6dea98`, the farmer harvested nothing in 187 seconds and retained its one seed: ![Baseline: mod crops remain unharvested](https://github.com/user-attachments/assets/e5981621-4a9c-4dae-a717-d37d0e78664f) On rebased `b77c973bd`, the server-thread run harvested all eight ripe crops on the mod farmland (right) and ended with nine replanted cells, one empty cell, and one seed left. The loam control (left) was not resown. The screenshot does not establish why the one farmland cell became empty: ![Fixed: mod farmland harvested and replanted](https://github.com/user-attachments/assets/90891b89-0672-455b-99d9-d464995a6c1b) The dedicated server (`--dedicated --nogui`, same mod and data pack) independently harvested all eight ripe farmland crops and ended with nine replanted cells, one empty cell, and one seed left. An earlier fixed integrated-server run reached 10/10 planted cells at 88 seconds. These live scenes used no bone meal; the final bonemeal-only correction is covered by the target-selection regression and independent QA above. Both attached images were downloaded anonymously and matched the original PNG SHA-256 hashes byte-for-byte. Reviewed with sol-loop: 3 rounds with GPT-6.1 Sol on xhigh. Sol verdict: approved 🤖 Generated with [OpenCode](https://opencode.ai), Claude Opus 5.5 and GPT-6.1 Sol. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:29:14 +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#6920
No description provided.