BlueGit

timfa copperfarmer

Widen the bundled farmer search, memory and timing defaults.

Co-authored-by: Cursor <cursoragent@cursor.com>

timfa Tim Falken · pushed by timfa

Authored 2026-08-14 · 3 months ago

Hash
6a31cef8d746f4800ca2e873e327f0bb2665e6e1
Parent
2187fb9b
4 files changed +16 −16
README.md +2 −2
@@ -16,8 +16,8 @@ Placing the special statue consumes it normally and replaces that placed statue
16 16
17 17 ## Farming behaviour
18 18
19 1. Bind the nearest **loaded** copper chest within the configured chunk radius (default: 2 chunks).
20 2. Every 10 seconds while idle, scan within 15 blocks of that chest for a mature supported crop.
19 1. Bind the nearest **loaded** copper chest within the configured chunk radius (default: 3 chunks).
20 2. Every 10 seconds while idle, scan within 25 blocks of that chest for a mature supported crop.
21 21 3. Pick a standable work position next to the crop and ask the native Pathfinder to navigate there.
22 22 4. Let vanilla keep/follow the path. If the golem stops making progress or loses its path, request one fresh path; failed targets receive a cooldown.
23 23 5. At the crop, calculate its loot using `Block#getDrops(storedCopperHoe, golem)`.
@@ -16,8 +16,8 @@ Placing the special statue consumes it normally and replaces that placed statue
16
16
17## Farming behaviour
17## Farming behaviour
18
18
191. Bind the nearest **loaded** copper chest within the configured chunk radius (default: 2 chunks).
191. Bind the nearest **loaded** copper chest within the configured chunk radius (default: 3 chunks).
202. Every 10 seconds while idle, scan within 15 blocks of that chest for a mature supported crop.
202. Every 10 seconds while idle, scan within 25 blocks of that chest for a mature supported crop.
213. Pick a standable work position next to the crop and ask the native Pathfinder to navigate there.
213. Pick a standable work position next to the crop and ask the native Pathfinder to navigate there.
224. Let vanilla keep/follow the path. If the golem stops making progress or loses its path, request one fresh path; failed targets receive a cooldown.
224. Let vanilla keep/follow the path. If the golem stops making progress or loses its path, request one fresh path; failed targets receive a cooldown.
235. At the crop, calculate its loot using `Block#getDrops(storedCopperHoe, golem)`.
235. At the crop, calculate its loot using `Block#getDrops(storedCopperHoe, golem)`.
src/main/java/nl/timfalken/copperfarmer/FarmerListener.java +1 −1
@@ -259,7 +259,7 @@ final class FarmerListener implements Listener {
259 259 if (place.getWorld() == null || !place.getWorld().getUID().toString().equals(snapshot.chestWorld())) {
260 260 return snapshot.withoutChest();
261 261 }
262 int radius = Math.max(0, plugin.getConfig().getInt("chest-memory-chunk-radius", 3));
262 int radius = Math.max(0, plugin.getConfig().getInt("chest-memory-chunk-radius", 5));
263 263 int dx = Math.abs((snapshot.chestX() >> 4) - (place.getBlockX() >> 4));
264 264 int dz = Math.abs((snapshot.chestZ() >> 4) - (place.getBlockZ() >> 4));
265 265 if (Math.max(dx, dz) > radius) return snapshot.withoutChest();
@@ -259,7 +259,7 @@ final class FarmerListener implements Listener {
259 if (place.getWorld() == null || !place.getWorld().getUID().toString().equals(snapshot.chestWorld())) {
259 if (place.getWorld() == null || !place.getWorld().getUID().toString().equals(snapshot.chestWorld())) {
260 return snapshot.withoutChest();
260 return snapshot.withoutChest();
261 }
261 }
262 int radius = Math.max(0, plugin.getConfig().getInt("chest-memory-chunk-radius", 3));
262 int radius = Math.max(0, plugin.getConfig().getInt("chest-memory-chunk-radius", 5));
263 int dx = Math.abs((snapshot.chestX() >> 4) - (place.getBlockX() >> 4));
263 int dx = Math.abs((snapshot.chestX() >> 4) - (place.getBlockX() >> 4));
264 int dz = Math.abs((snapshot.chestZ() >> 4) - (place.getBlockZ() >> 4));
264 int dz = Math.abs((snapshot.chestZ() >> 4) - (place.getBlockZ() >> 4));
265 if (Math.max(dx, dz) > radius) return snapshot.withoutChest();
265 if (Math.max(dx, dz) > radius) return snapshot.withoutChest();
src/main/java/nl/timfalken/copperfarmer/FarmerManager.java +4 −4
@@ -72,8 +72,8 @@ final class FarmerManager {
72 72 this.cropRegistry = cropRegistry;
73 73 this.seedRecipes = seedRecipes;
74 74 this.itemCodec = itemCodec;
75 this.chestChunkRadius = Math.max(0, plugin.getConfig().getInt("chest-search-chunk-radius", 2));
76 this.cropRadius = Math.max(1, plugin.getConfig().getInt("crop-radius", 15));
75 this.chestChunkRadius = Math.max(0, plugin.getConfig().getInt("chest-search-chunk-radius", 3));
76 this.cropRadius = Math.max(1, plugin.getConfig().getInt("crop-radius", 25));
77 77 this.scanInterval = Math.max(20, plugin.getConfig().getLong("scan-interval-ticks", 200));
78 78 this.moveSpeed = Math.max(0.1, plugin.getConfig().getDouble("move-speed", 1.0));
79 79 this.stuckTimeout = Math.max(20, plugin.getConfig().getLong("stuck-timeout-ticks", 60));
@@ -81,8 +81,8 @@ final class FarmerManager {
81 81 this.unreachableCooldown = Math.max(20, plugin.getConfig().getLong("unreachable-crop-cooldown-ticks", 600));
82 82 double actionDistance = Math.max(1.25, plugin.getConfig().getDouble("action-distance", 2.25));
83 83 this.actionDistanceSquared = actionDistance * actionDistance;
84 this.plantWindupTicks = Math.max(0L, plugin.getConfig().getLong("plant-windup-ticks", 10L));
85 this.afterDepositScanTicks = Math.max(1L, plugin.getConfig().getLong("after-deposit-scan-ticks", 20L));
84 this.plantWindupTicks = Math.max(0L, plugin.getConfig().getLong("plant-windup-ticks", 30L));
85 this.afterDepositScanTicks = Math.max(1L, plugin.getConfig().getLong("after-deposit-scan-ticks", 40L));
86 86 this.cargoSlots = Math.max(1, plugin.getConfig().getInt("cargo-slots", 9));
87 87 this.preventOxidation = plugin.getConfig().getBoolean("prevent-oxidation", false);
88 88 }
@@ -72,8 +72,8 @@ final class FarmerManager {
72 this.cropRegistry = cropRegistry;
72 this.cropRegistry = cropRegistry;
73 this.seedRecipes = seedRecipes;
73 this.seedRecipes = seedRecipes;
74 this.itemCodec = itemCodec;
74 this.itemCodec = itemCodec;
75 this.chestChunkRadius = Math.max(0, plugin.getConfig().getInt("chest-search-chunk-radius", 2));
75 this.chestChunkRadius = Math.max(0, plugin.getConfig().getInt("chest-search-chunk-radius", 3));
76 this.cropRadius = Math.max(1, plugin.getConfig().getInt("crop-radius", 15));
76 this.cropRadius = Math.max(1, plugin.getConfig().getInt("crop-radius", 25));
77 this.scanInterval = Math.max(20, plugin.getConfig().getLong("scan-interval-ticks", 200));
77 this.scanInterval = Math.max(20, plugin.getConfig().getLong("scan-interval-ticks", 200));
78 this.moveSpeed = Math.max(0.1, plugin.getConfig().getDouble("move-speed", 1.0));
78 this.moveSpeed = Math.max(0.1, plugin.getConfig().getDouble("move-speed", 1.0));
79 this.stuckTimeout = Math.max(20, plugin.getConfig().getLong("stuck-timeout-ticks", 60));
79 this.stuckTimeout = Math.max(20, plugin.getConfig().getLong("stuck-timeout-ticks", 60));
@@ -81,8 +81,8 @@ final class FarmerManager {
81 this.unreachableCooldown = Math.max(20, plugin.getConfig().getLong("unreachable-crop-cooldown-ticks", 600));
81 this.unreachableCooldown = Math.max(20, plugin.getConfig().getLong("unreachable-crop-cooldown-ticks", 600));
82 double actionDistance = Math.max(1.25, plugin.getConfig().getDouble("action-distance", 2.25));
82 double actionDistance = Math.max(1.25, plugin.getConfig().getDouble("action-distance", 2.25));
83 this.actionDistanceSquared = actionDistance * actionDistance;
83 this.actionDistanceSquared = actionDistance * actionDistance;
84 this.plantWindupTicks = Math.max(0L, plugin.getConfig().getLong("plant-windup-ticks", 10L));
84 this.plantWindupTicks = Math.max(0L, plugin.getConfig().getLong("plant-windup-ticks", 30L));
85 this.afterDepositScanTicks = Math.max(1L, plugin.getConfig().getLong("after-deposit-scan-ticks", 20L));
85 this.afterDepositScanTicks = Math.max(1L, plugin.getConfig().getLong("after-deposit-scan-ticks", 40L));
86 this.cargoSlots = Math.max(1, plugin.getConfig().getInt("cargo-slots", 9));
86 this.cargoSlots = Math.max(1, plugin.getConfig().getInt("cargo-slots", 9));
87 this.preventOxidation = plugin.getConfig().getBoolean("prevent-oxidation", false);
87 this.preventOxidation = plugin.getConfig().getBoolean("prevent-oxidation", false);
88 }
88 }
src/main/resources/config.yml +9 −9
@@ -1,15 +1,15 @@
1 1 # How many chunks around a newly spawned / chestless farmer are searched.
2 chest-search-chunk-radius: 2
2 chest-search-chunk-radius: 3
3 3
4 4 # When a farmer statue is placed, forget the bound chest if it is farther than this
5 # Chebyshev chunk distance (default: more than 3 chunks away).
6 chest-memory-chunk-radius: 3
5 # Chebyshev chunk distance (default: more than 5 chunks away).
6 chest-memory-chunk-radius: 5
7 7
8 8 # Crops must be within this Euclidean distance of the bound chest.
9 crop-radius: 15
9 crop-radius: 25
10 10
11 11 # An idle farmer retries a crop scan this often when nothing was found. 200 ticks = 10 seconds.
12 # After a successful chest dump the farmer waits 1 second instead (after-deposit-scan-ticks).
12 # After a successful chest dump the farmer waits 2 seconds instead (after-deposit-scan-ticks).
13 13 scan-interval-ticks: 200
14 14
15 15 # State-machine update interval. Pathfinding itself remains vanilla.
@@ -30,11 +30,11 @@ unreachable-crop-cooldown-ticks: 600
30 30 # Distance from the target block at which harvesting/planting/depositing is allowed.
31 31 action-distance: 2.25
32 32
33 # After arriving at empty farmland, wait this long before planting. 10 ticks = 0.5 seconds.
34 plant-windup-ticks: 10
33 # After arriving at empty farmland, wait this long before planting. 30 ticks = 1.5 seconds.
34 plant-windup-ticks: 30
35 35
36 # After a successful cargo dump, wait this long before scanning for the next crop. 20 ticks = 1 second.
37 after-deposit-scan-ticks: 20
36 # After a successful cargo dump, wait this long before scanning for the next crop. 40 ticks = 2 seconds.
37 after-deposit-scan-ticks: 40
38 38
39 39 # Maximum internal cargo stacks. Partial stacks are combined first.
40 40 cargo-slots: 9
@@ -1,15 +1,15 @@
1# How many chunks around a newly spawned / chestless farmer are searched.
1# How many chunks around a newly spawned / chestless farmer are searched.
2chest-search-chunk-radius: 2
2chest-search-chunk-radius: 3
3
3
4# When a farmer statue is placed, forget the bound chest if it is farther than this
4# When a farmer statue is placed, forget the bound chest if it is farther than this
5# Chebyshev chunk distance (default: more than 3 chunks away).
5# Chebyshev chunk distance (default: more than 5 chunks away).
6chest-memory-chunk-radius: 3
6chest-memory-chunk-radius: 5
7
7
8# Crops must be within this Euclidean distance of the bound chest.
8# Crops must be within this Euclidean distance of the bound chest.
9crop-radius: 15
9crop-radius: 25
10
10
11# An idle farmer retries a crop scan this often when nothing was found. 200 ticks = 10 seconds.
11# An idle farmer retries a crop scan this often when nothing was found. 200 ticks = 10 seconds.
12# After a successful chest dump the farmer waits 1 second instead (after-deposit-scan-ticks).
12# After a successful chest dump the farmer waits 2 seconds instead (after-deposit-scan-ticks).
13scan-interval-ticks: 200
13scan-interval-ticks: 200
14
14
15# State-machine update interval. Pathfinding itself remains vanilla.
15# State-machine update interval. Pathfinding itself remains vanilla.
@@ -30,11 +30,11 @@ unreachable-crop-cooldown-ticks: 600
30# Distance from the target block at which harvesting/planting/depositing is allowed.
30# Distance from the target block at which harvesting/planting/depositing is allowed.
31action-distance: 2.25
31action-distance: 2.25
32
32
33# After arriving at empty farmland, wait this long before planting. 10 ticks = 0.5 seconds.
33# After arriving at empty farmland, wait this long before planting. 30 ticks = 1.5 seconds.
34plant-windup-ticks: 10
34plant-windup-ticks: 30
35
35
36# After a successful cargo dump, wait this long before scanning for the next crop. 20 ticks = 1 second.
36# After a successful cargo dump, wait this long before scanning for the next crop. 40 ticks = 2 seconds.
37after-deposit-scan-ticks: 20
37after-deposit-scan-ticks: 40
38
38
39# Maximum internal cargo stacks. Partial stacks are combined first.
39# Maximum internal cargo stacks. Partial stacks are combined first.
40cargo-slots: 9
40cargo-slots: 9