[PR #7828] A villager's food is the item's villager_food component #7846

Open
opened 2026-11-03 07:25:15 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7828
Author: @xFedeT
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/villager-food-component


📝 Commits (1)

  • f90541e A villager's food is the item's villager_food component

📊 Changes

2 files changed (+72 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/mobs/villager.rs (+6 -2)
📝 crates/horizon-items/src/items.rs (+66 -0)

📄 Description

🤖 Opened by xFedeT's AI agent (Claude Code, Sonnet 5.5), not by xFedeT personally.

Fixes #7821

Vanilla reads DataComponents.VILLAGER_FOOD wherever a villager checks food (eating, counting, breeding, TradeWithVillager, picking up). mobs/villager.rs::food_points matched bread, potato, carrot and beetroot by id, so an item given the component never counted.

ItemInfo now has villager_food (the component's nutrition, parsed with the other defaults), and loading the item registry hands the table to horizon_items::items::villager_food, which food_points reads (a mob does not hold the registry, so there is one process-wide table, replaced by each load). Until a registry is loaded (unit tests) the four vanilla foods stay as the fallback. Every user of food_points (inventory count, eating, sharing, pickup, breeding) follows.

Test: the_registry_tells_a_villagers_food (bread 4, carrot, potato and beetroot 1, apple none; needs the prepared data, skipped without it). cargo test -p horizon-items --lib villager_food, cargo test -p horizon-client-lib --lib villager, clippy.

Not covered: a component set on one stack (as opposed to an item's default) and an item a mod adds at run time are not read; both need the stack's or the mod's data, which food_points(&str) is not given.

🤖 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/7828 **Author:** [@xFedeT](https://github.com/xFedeT) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/villager-food-component` --- ### 📝 Commits (1) - [`f90541e`](https://github.com/horizon-rust/horizon/commit/f90541efef4badd9f9d2aeaeb9fc7c7a14167e49) A villager's food is the item's villager_food component ### 📊 Changes **2 files changed** (+72 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mobs/villager.rs` (+6 -2) 📝 `crates/horizon-items/src/items.rs` (+66 -0) </details> ### 📄 Description > 🤖 Opened by xFedeT's AI agent (Claude Code, Sonnet 5.5), not by xFedeT personally. Fixes #7821 Vanilla reads `DataComponents.VILLAGER_FOOD` wherever a villager checks food (eating, counting, breeding, `TradeWithVillager`, picking up). `mobs/villager.rs::food_points` matched bread, potato, carrot and beetroot by id, so an item given the component never counted. `ItemInfo` now has `villager_food` (the component's `nutrition`, parsed with the other defaults), and loading the item registry hands the table to `horizon_items::items::villager_food`, which `food_points` reads (a mob does not hold the registry, so there is one process-wide table, replaced by each load). Until a registry is loaded (unit tests) the four vanilla foods stay as the fallback. Every user of `food_points` (inventory count, eating, sharing, pickup, breeding) follows. Test: `the_registry_tells_a_villagers_food` (bread 4, carrot, potato and beetroot 1, apple none; needs the prepared data, skipped without it). `cargo test -p horizon-items --lib villager_food`, `cargo test -p horizon-client-lib --lib villager`, clippy. Not covered: a component set on one stack (as opposed to an item's default) and an item a mod adds at run time are not read; both need the stack's or the mod's data, which `food_points(&str)` is not given. 🤖 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>
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#7846
No description provided.