BlueGit

timfa copperfarmer

Overview

Activity

NovDecJanFebMarAprMayJunJulAugSepOctNov

83 contributions in the last 12 months

LessMore

Commits, merge requests and comments.

copperfarmer
chore: bump version to 0.1.19
timfa GitLab CI · pushed by timfa · 2 months ago
90fedde5 History
README.md

CopperFarmer 0.1.19

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/.