ValheimFarmerNPC
Autonomous goblin farmers for Valheim. Place a homestead, mark your field, assign chests - farmers plant, harvest, and store crops. Multiplayer-safe; server and clients need the mod.Valheim Farmer NPC
Autonomous farming NPCs for Valheim. Place a Farmer Homestead, mark your cultivated field with Boundary Posts, assign chests, and let goblin farmers plant, harvest, and store crops while you stay nearby.
| Version | 1.0.13 |
| Author | Pjanky |
| Thunderstore | Pjanky-ValheimFarmerNPC |
| License | MIT |
| Requires | BepInExPack Valheim + Jötunn |
| Install on | Dedicated server and all clients (same version) |
How it works
- The Homestead piece stores all persistent farm data (crop slots, chests, pause state, crop settings) on its network object (ZDO).
- Farmer NPCs are temporary workers that exist while a player keeps the farm zone loaded. They are not permanent world creatures.
- AI runs on the peer that owns the farmer’s network view (
IsOwner()), which keeps multiplayer safe without forcing dedicated-server ownership of every NPC. - If you leave the area and farmers disappear, that is expected. Homestead data and the field remain. Come back, open the Homestead, and use Add Farmer / unpause again.
Talking to a farmer toggles pause/resume for that homestead’s work.
Installation
With r2modman / Thunderstore Mod Manager
- Install BepInExPack Valheim and Jötunn.
- Install Valheim Farmer NPC (
Pjanky-ValheimFarmerNPC). - Use the same profile/mod list on the dedicated server and every client.
Manual
- Install BepInEx for Valheim and Jötunn.
- Copy
ValheimFarmerNPC.dllintoBepInEx/plugins/ValheimFarmerNPC/(server and clients). - Launch once so the config file is created under
BepInEx/config/.
Custom hammer pieces: Farmer Homestead, Farm Boundary Post.
Complete setup walkthrough
Default config only allows admins to place Homestead/Boundary pieces and open the Homestead panel. Set AdminOnlyPlacement / AdminOnlyAccess to false if you want any player to manage farms.
1. Cultivate and plant a starter field (optional but recommended)
Till soil and plant at least some crops yourself (or leave empty cultivated plots). A scan discovers existing plants and empty plantable spots inside the boundary.
2. Place the Farmer Homestead
- Open the hammer and find Farmer Homestead.
- Place it near your farm (facing the field is fine; exact facing is not critical).
- Interact with the Homestead to open the Farmer Homestead panel.
Status at the top shows pause state, farmer count, crop slot count, chest count, and whether a boundary is set.
3. Place Boundary Posts
- Place two Farm Boundary Posts at opposite corners of the rectangle that should cover your farm.
- The posts define an axis-aligned box on the ground (XZ). Keep each half-width within
MaxFarmRadius(default 64 m), or scanning will fail.
Tip: Place posts just outside the cultivated plots so every plantable tile is inside the box.
4. Assign Boundary Posts
On the Homestead panel → Field section:
- Click Assign Boundary Posts.
- The mod finds nearby boundary posts and binds them to this homestead.
- Status should show
Boundary: set.
If assignment fails, move closer, ensure both posts exist, and try again.
5. Scan the field
- Click Scan Field.
- The homestead inventories plants and empty cultivated slots inside the boundary.
- Status Crops count should rise above zero.
Use Clear Field only when you want to wipe the homestead’s remembered slot list (for a full rescan after big layout changes). It does not destroy plants in the world by itself—re-scan after clearing if you still want farmers to work that field.
6. Assign chests (storage)
Farmers need containers for seeds/harvests.
- Place normal Valheim chests (or compatible containers) near the homestead.
- Click Add chest — assigns the nearest free chest within
ChestAssignRange(default 20 m). - Repeat Add chest until you have enough storage.
- Clear chests unassigns all chests from this homestead (items in the chests are not deleted).
- Chest inventory opens a page listing aggregated contents of assigned chests.
7. Configure crop settings
Open Crop settings.
- The page shows the homestead’s biome (top right).
- Only crops that can grow in that biome appear.
- Unavailable crops are zeroed for planting automatically.
Weights (left column)
Relative planting ratios. Higher weight → planted more often when filling empty slots. Set a crop to 0 to skip planting it (harvest of existing plants can still happen).
Reserves (right column)
Minimum stock kept in the farmer’s bag. For Carrot/Turnip/Onion this is seeds; for Barley, Flax, Jotun Puffs, and Magecap it is the crop item itself (planted like vanilla). When stock falls below the reserve, farmers prioritize growing seed-crops (or restocking) until the reserve recovers.
Click Back when done.
Biome → plantable crops
| Biome | Crops shown / plantable |
|---|---|
| Meadows, Black Forest, Ocean | Carrot, Turnip, Onion |
| Swamp | Turnip |
| Plains | Carrot, Turnip, Onion, Barley, Flax |
| Mistlands | Jotun Puffs, Magecap |
| Mountains, Deep North, Ashlands | None |
Homestead position decides the biome. Fields that straddle biome borders may need the homestead on the side you intend to farm.
8. Add farmers and start work
- Stay near the homestead so the zone stays loaded. Placing a Homestead already spawns one farmer.
- Use Add Farmer for more workers, or if the worker went missing after you left the area.
- Ensure status is Working (not Paused). Use Toggle Pause if needed.
- Farmers will harvest mature crops, plant empty slots according to weights/reserves, fetch materials from chests, and deposit overflow.
Remove Farmer despawns one farmer at this homestead (useful if you added too many). Global cap: MaxFarmers (default 16 across the whole world).
Deposit all forces farmers to empty carried goods into assigned chests when possible.
9. Day-to-day use
- Keep a player near the farm while you want work done.
- Interact with the Homestead anytime to check status, inventories, or crop settings.
- Talk to a farmer to pause/resume.
- After long absences: open Homestead → Add Farmer if none are present → ensure not paused → optionally Scan Field if you changed the field by hand.
Homestead UI pages
Main — Farmer Homestead
Overview and all primary actions.
| Control | Purpose |
|---|---|
| Status text | Paused/Working, farmer count, crop slots, chests, boundary set/missing |
| Toggle Pause | Pause or resume farming for this homestead |
| Add Farmer | Spawn another farmer, or recover one missing after leaving the area |
| Remove Farmer | Remove one farmer from this homestead |
| Deposit all | Push carried items into assigned chests |
| Farmer inventory | Open live bags page |
| Scan Field | Discover/update crop slots inside the boundary |
| Clear Field | Clear remembered slot data (re-scan afterward) |
| Assign Boundary Posts | Bind the two nearby boundary posts |
| Add chest | Assign nearest free chest in range |
| Clear chests | Unassign all chests from this homestead |
| Chest inventory | Browse assigned chest contents |
| Crop settings | Weights, reserves, biome-filtered crops |
| Close | Close the panel |
Crop settings
Two columns for biome-legal food crops only.
| Section | Purpose |
|---|---|
| Biome label | Which biome rules apply at the homestead |
| Weights | Planting ratios (0 = do not plant) |
| Reserves | Minimum seed/crop stock farmers try to keep |
| Back | Return to main |
Empty biomes show a message that no crops grow there.
Farmer inventory
Live view of items in farmer bags near this homestead (aggregated).
| Control | Purpose |
|---|---|
| Status | Farmer count and item-type count |
| List | Icons + stacks |
| Total items | Sum of stacks (footer) |
| Refresh | Reload from current farmers |
| Back | Return to main |
Chest inventory
Aggregated contents of all chests assigned to this homestead.
| Control | Purpose |
|---|---|
| Status | Chest count and item-type count |
| List | Icons + stacks |
| Total items | Sum of stacks (footer) |
| Refresh | Reload from assigned chests |
| Back | Return to main |
Configuration
After first launch, edit:
BepInEx/config/com.farmerjohn.valheimfarmernpc.cfg
On dedicated servers, treat these as server-authoritative for gameplay limits. Restart (or reconnect) after changes as needed.
General
| Setting | Default | Description |
|---|---|---|
| AdminOnlyPlacement | true |
Only server admins may place or remove Farmer Homestead and Boundary Post pieces. |
| AdminOnlyAccess | true |
Only admins can open the homestead panel and change settings. Set false to let any player manage farms. |
| MaxFarmers | 16 |
Hard cap on active farmer NPCs across the whole world/server. |
Farming
| Setting | Default | Description |
|---|---|---|
| MaxFarmRadius | 64 |
Max half-width (meters) of the farm boundary on X or Z. Larger fields fail to scan. |
| DefaultLayoutMode | Weighted |
Planting mode for new homesteads: Weighted uses Crop settings ratios; Fixed replants each slot’s original crop when possible. Changing weights in the UI switches that homestead to Weighted. |
| ScanInterval | 2 |
Seconds between background field refreshes while farmers work (growth / empty-slot detection). |
| ChestAssignRange | 20 |
Max distance (meters) from the homestead when using Add chest. |
Inventory
| Setting | Default | Description |
|---|---|---|
| InventoryCapacity | 20 |
Max distinct item stacks a farmer can carry (not total item count). |
Networking
| Setting | Default | Description |
|---|---|---|
| ReservationTimeout | 30 |
Seconds a harvest/plant slot reservation lasts before another farmer may take it (multiplayer). |
AI
| Setting | Default | Description |
|---|---|---|
| EnableFarmerSounds | true |
Fuling/goblin vocal sounds. Set false to mute farmers. |
| ThinkInterval | 0.5 |
Seconds between AI decision ticks. Lower = more responsive, more CPU. |
| MoveSpeed | 2.5 |
Walking speed when moving between tasks. |
| WorkRange | 2 |
Distance (meters) to harvest, plant, or use a chest. |
Debug / UI
| Setting | Default | Description |
|---|---|---|
| DebugLogging | false |
Verbose AI logs. Can hurt FPS with the console open; leave off for normal play. |
| LogFeedbackToChat | true |
Also write homestead feedback (scan, boundary, chests, farmers, …) to chat. Center-screen messages always show. |
Per-homestead crop weights and reserves are not in this file — they are stored on each Homestead and edited in Crop settings.
Multiplayer notes
- Install the same mod version on server and clients (
EveryoneMustHaveMod). - Homestead data persists in the world save via the piece ZDO.
- Multiple farmers on one homestead share the field; reservations avoid two NPCs claiming the same plant/slot.
- Farmers only work while someone keeps the zone loaded.
Troubleshooting
| Issue | What to try |
|---|---|
| Cannot place Homestead / posts | You are not admin and AdminOnlyPlacement is true. |
| Cannot open panel | AdminOnlyAccess is true and you are not admin. |
| Boundary missing / scan fails | Assign two posts; ensure field size ≤ MaxFarmRadius; posts must form a real rectangle. |
| No crops in Crop settings | Homestead biome has no farmable crops (e.g. Mountains), or scan never ran. |
| Farmers idle | Paused; no empty/mature work; no seeds/materials in bags/chests; zone unloaded. |
| Farmers vanished | Normal when you left the area — Add Farmer again while nearby. |
| Chests not assigned | Move chests closer than ChestAssignRange; use Add chest again. |
Development
Repository: github.com/nico8034/FarmerNPC
# Local Debug build → r2modman Default profile plugins
powershell -ExecutionPolicy Bypass -File ValheimFarmerNPC/scripts/deploy-local.ps1
# Thunderstore zip → ValheimFarmerNPC/dist/
# (bump Plugin.PluginVersion first; update Package/CHANGELOG.md)
powershell -ExecutionPolicy Bypass -File ValheimFarmerNPC/scripts/package-thunderstore.ps1
Also copy Environment.props.example → Environment.props and set VALHEIM_INSTALL for IDE/Jötunn post-build deploy.
Version source of truth: Plugin.PluginVersion in Plugin.cs (semantic versioning: Major.Minor.Patch).
License
Licensed under the MIT License. Valheim is © Iron Gate AB — this mod requires a legitimate copy of the game.
