BlueGit

timfa copperfarmer

Files

copperfarmer / README.md

README.md

chore: bump version to 0.1.22
timfa GitLab CI · pushed by timfa · 2 months ago
71c4df13 History
README.md 4.4 KiB Download Raw

CopperFarmer 0.1.22

First-version Paper 26.2 / Java 25 plugin for autonomous Copper Farmer Golems.

Crafting

Shapeless recipe:

  • 1x Copper Golem Statue
  • 1x Copper Hoe
  • -> 1x Copper Farmer Golem statue

For player crafting and vanilla Crafters, the output stores the exact Copper Hoe used in the recipe (one item), including its durability, enchantments, name and other item data. That stored hoe is equipped on the golem, used as the tool for crop loot calculation, and returned on death.

Placing the special statue consumes it normally and replaces that placed statue with a tagged real CopperGolem on the next tick. All vanilla goals are removed. Minecraft/Paper's native Pathfinder remains responsible for navigation.

Farming behaviour

1. Bind the nearest loaded copper chest within the configured chunk radius (default: 3 chunks). 2. Every 10 seconds while idle, scan within 25 blocks of that chest for a mature supported crop. 3. Pick a standable work position next to the crop and ask the native Pathfinder to navigate there. 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. 5. At the crop, calculate its loot using Block#getDrops(storedCopperHoe, golem). 6. Put the calculated drops into persistent internal cargo, then remove the crop block. 7. Replant from a seed/crop already in cargo. If none exists, try one cached crop-to-seed crafting conversion. 8. For farmland crops, use remaining seeds on connected empty farmland, navigating to each planting point. 9. Return to the bound copper chest and deposit the cargo. 10. If the chest is full, keep leftovers and retry later. If the chest disappears or proves unreachable, search for another chest. 11. On death, drop the exact construction hoe and every item still in persistent cargo.

Supported crops in 0.1.0

  • Wheat
  • Carrots
  • Potatoes
  • Beetroot
  • Nether Wart
  • Cocoa
  • Sweet Berry Bushes
  • Torchflowers
  • Melons — fruit only; attached stem is left intact
  • Pumpkins — fruit only; attached stem is left intact

The crop registry is isolated from the state machine, so more vanilla/Matcha-specific crop handlers can be added later without rewriting navigation or chest logic. Pitcher crops, cave vines, sugar cane and bamboo are deliberately not special-cased in this first version because their harvest/replant rules differ from a normal single-block ageable crop.

Seed recipe cache

The cache is built once on the first server tick after plugin enable. During normal startup, that is after other plugins have had their onEnable(), so their registered recipes are included as well.

A shaped/shapeless recipe is cached when:

  • its result is a seed item used by a registered crop;
  • every occupied ingredient slot can be satisfied by the same input material.

For shaped recipes, repeated shape cells are counted individually. This deliberately recognises crop/item -> seed conversions without turning the farmer into a general autocrafter.

The farmer never searches the recipe registry while working. Recipe changes after this cache is built are intentionally ignored until CopperFarmer/server restart or reload.

Persistence and behaviour notes

  • Farmer identity, bound chest, exact construction hoe and cargo are stored in PDC.
  • Cargo uses Paper's NBT ItemStack byte serialization, so arbitrary item metadata survives chunk unloads/restarts.
  • Only loaded chunks are searched; CopperFarmer never force-loads chunks.
  • Internal cargo defaults to 9 stacks. If a datapack produces an unusually huge single harvest that cannot fit, only the overflow is dropped at the crop rather than deleted.
  • Farmer Copper Golems are internally kept waxed by default (prevent-oxidation: true) so they do not eventually oxidise out of service. This is configurable.
  • The golem swings its main hand when harvesting/planting. Whether the Copper Golem client renderer visibly renders held equipment is client-side; the equipment slot itself is populated regardless.
  • No fake player BlockBreakEvent is generated. Loot is calculated from the real block loot table with the stored hoe and farmer golem as context.
  • The stored construction hoe is not damaged by farming in 0.1.0; it is used as loot/tool context only.

Build

The project targets the official Paper 26.2 API build 26.2.build.112-stable and Java 25.

With Gradle installed:

gradle build

The resulting JAR will be under build/libs/.

Source
1# CopperFarmer 0.1.22
2
3First-version Paper 26.2 / Java 25 plugin for autonomous Copper Farmer Golems.
4
5## Crafting
6
7Shapeless recipe:
8
9- 1x Copper Golem Statue
10- 1x Copper Hoe
11- -> 1x **Copper Farmer Golem** statue
12
13For player crafting and vanilla Crafters, the output stores the **exact Copper Hoe used in the recipe** (one item), including its durability, enchantments, name and other item data. That stored hoe is equipped on the golem, used as the tool for crop loot calculation, and returned on death.
14
15Placing the special statue consumes it normally and replaces that placed statue with a tagged real `CopperGolem` on the next tick. All vanilla goals are removed. Minecraft/Paper's native Pathfinder remains responsible for navigation.
16
17## Farming behaviour
18
191. Bind the nearest **loaded** copper chest within the configured chunk radius (default: 3 chunks).
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.
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)`.
246. Put the calculated drops into persistent internal cargo, then remove the crop block.
257. Replant from a seed/crop already in cargo. If none exists, try **one** cached crop-to-seed crafting conversion.
268. For farmland crops, use remaining seeds on connected empty farmland, navigating to each planting point.
279. Return to the bound copper chest and deposit the cargo.
2810. If the chest is full, keep leftovers and retry later. If the chest disappears or proves unreachable, search for another chest.
2911. On death, drop the exact construction hoe and every item still in persistent cargo.
30
31## Supported crops in 0.1.0
32
33- Wheat
34- Carrots
35- Potatoes
36- Beetroot
37- Nether Wart
38- Cocoa
39- Sweet Berry Bushes
40- Torchflowers
41- Melons — fruit only; attached stem is left intact
42- Pumpkins — fruit only; attached stem is left intact
43
44The crop registry is isolated from the state machine, so more vanilla/Matcha-specific crop handlers can be added later without rewriting navigation or chest logic. Pitcher crops, cave vines, sugar cane and bamboo are deliberately not special-cased in this first version because their harvest/replant rules differ from a normal single-block ageable crop.
45
46## Seed recipe cache
47
48The cache is built **once on the first server tick after plugin enable**. During normal startup, that is after other plugins have had their `onEnable()`, so their registered recipes are included as well.
49
50A shaped/shapeless recipe is cached when:
51
52- its result is a seed item used by a registered crop;
53- every occupied ingredient slot can be satisfied by the **same input material**.
54
55For shaped recipes, repeated shape cells are counted individually. This deliberately recognises crop/item -> seed conversions without turning the farmer into a general autocrafter.
56
57The farmer never searches the recipe registry while working. Recipe changes after this cache is built are intentionally ignored until CopperFarmer/server restart or reload.
58
59## Persistence and behaviour notes
60
61- Farmer identity, bound chest, exact construction hoe and cargo are stored in PDC.
62- Cargo uses Paper's NBT ItemStack byte serialization, so arbitrary item metadata survives chunk unloads/restarts.
63- Only loaded chunks are searched; CopperFarmer never force-loads chunks.
64- Internal cargo defaults to 9 stacks. If a datapack produces an unusually huge single harvest that cannot fit, only the overflow is dropped at the crop rather than deleted.
65- Farmer Copper Golems are internally kept waxed by default (`prevent-oxidation: true`) so they do not eventually oxidise out of service. This is configurable.
66- The golem swings its main hand when harvesting/planting. Whether the Copper Golem client renderer visibly renders held equipment is client-side; the equipment slot itself is populated regardless.
67- No fake player `BlockBreakEvent` is generated. Loot is calculated from the real block loot table with the stored hoe and farmer golem as context.
68- The stored construction hoe is not damaged by farming in 0.1.0; it is used as loot/tool context only.
69
70## Build
71
72The project targets the official Paper 26.2 API build `26.2.build.112-stable` and Java 25.
73
74With Gradle installed:
75
76```bash
77gradle build
78```
79
80The resulting JAR will be under `build/libs/`.