AutoHarvest
适用于 Paper 1.21.x 的原生增强型自动收获与重种植模组
破坏成熟的作物,它会自动重新种植。使用骨粉右键点击,即可在单次操作中完成生长、收获和重新种植。无作弊、无复制、无 TPS 影响。这只是原版遗忘的一项便利性(QoL)功能。
功能特性
破坏式收获
破坏任何成熟的作物,它会正常掉落物品——然后在生长阶段 0 自动重新种植。原版负责处理破坏、掉落、工具耐久度、附魔、经验值和统计数据。AutoHarvest 仅增加重新种植这一行为。
骨粉式收获
使用骨粉右键点击未成熟的作物。原版会推进其生长进度。如果该次应用使作物变为成熟状态,AutoHarvest 将对其进行收获、掉落物品并重新种植——全部在一次点击中完成。每次使用消耗一个骨粉,与原版行为完全一致。
种子公平性
骨粉路径会从掉落物中扣除一个种子以防止复制。如果没有此机制,每次通过骨粉收获都会产生免费的种子(因为作物被重新种植,但掉落物中包含重新种植的成本)。AutoHarvest 强制执行净零损耗:通过骨粉收获产生的掉落物数量与手动破坏并重新种植的结果相同。
按玩家切换
/autoharvest toggle —— 想要纯原版体验的玩家可以选择退出。状态通过 PersistentDataContainer 在重新登录和服务器重启后保持持久化。无需数据库支持。
支持的作物
| 作物 |
重新种植年龄 |
备注 |
| Wheat (小麦) |
0 |
标准可生长作物 |
| Carrots (胡萝卜) |
0 |
标准可生长作物 |
| Potatoes (土豆) |
0 |
保留毒土豆的掉落 |
| Beetroot (甜菜根) |
0 |
标准可生长作物 |
| Nether Wart (下界疣) |
0 |
重新种植前验证下方是否有灵魂沙 |
| Cocoa Beans (可可豆) |
0 |
保留朝向方向,验证是否为丛林原木 |
| Sweet Berries (甜浆果) |
1 |
匹配原版右键收获的手感 |
明确不支持的作物
- Sugar cane (甘蔗), bamboo (竹子), cactus (仙人掌), kelp (海带) —— 垂直生长,活塞可能导致复制风险
- Melons (西瓜), pumpkins (南瓜) —— 基于茎部生成,实际上已具备自动重新种植特性
- Chorus fruit (紫颂果) —— 不属于农场作物
命令
| 命令 |
描述 |
权限 |
/autoharvest toggle |
切换自身状态 |
autoharvest.use |
/autoharvest toggle <player> |
切换其他玩家的状态 |
autoharvest.admin.toggle-others |
/autoharvest info |
显示状态、版本、启用的作物列表 |
autoharvest.use |
/autoharvest reload |
重载配置 |
autoharvest.admin.reload |
别名:/ah 可用于所有命令。
权限
| 权限 |
默认值 |
描述 |
autoharvest.use |
true |
切换和信息命令 |
autoharvest.break |
true |
破坏作物时自动收获 |
autoharvest.bonemeal |
true |
通过骨粉自动收获 |
autoharvest.admin |
op |
所有管理命令 |
autoharvest.admin.reload |
op |
重载配置 |
autoharvest.admin.toggle-others |
op |
切换其他玩家的状态 |
在配置文件中设置 require-permission: true 以要求拥有 autoharvest.use 权限才能使用该插件。默认情况下,它对所有人可用。
配置
所有设置均位于 plugins/AutoHarvest/config.yml 中。更改配置后执行 /autoharvest reload 即可生效——无需重启服务器。
general:
default-enabled: true # 新玩家默认开启自动收获
require-permission: false # 是否需要 autoharvest.use 权限
enabled-worlds: [] # 空表示所有世界。列出特定世界以限制范围。
disabled-worlds: # 这些世界始终被排除
- "world_nether"
- "world_the_end"
harvest:
on-break: true # 破坏成熟作物时自动重新种植
on-bonemeal: true # 使用骨粉催熟至成熟时收获并重新种植
require-hoe: false # 仅在手持锄头时触发
bonemeal-subtract-replant-cost: true # 公平性:从骨粉收获掉落中扣除 1 个种子
drops:
enabled: true # 设为 false 以抑制所有掉落(适用于冒险地图)
drop-at-center: true # 在方块中心而非精确破坏位置掉落
overflow-to-ground: true # 背包已满?将多余物品掉落在地面上,而非虚空
crops: # 启用/禁用单个作物类型
wheat: true
carrots: true
potatoes: true
beetroot: true
nether_wart: true
cocoa: true
sweet_berries: true
cooldown:
bonemeal-ms: 50 # 防宏:每个玩家骨粉收获之间的最小间隔(毫秒)
feedback:
particles: true # 收获时显示绿色闪烁粒子效果
sound: true # 收获时播放作物破坏音效
sound-name: "block.crop.break"
sound-volume: 0.5
sound-pitch: 1.2
debug: false # 记录每次收获,包含玩家、位置、作物、掉落物信息
消息可在 messages.yml 中使用 MiniMessage 格式 进行自定义。
工作原理
AutoHarvest 的设计目标是让游戏引擎感知不到它的存在。它从不取消事件或重新实现原版机制。
破坏路径
- 玩家破坏一个成熟的作物
BlockBreakEvent 以 HIGH 优先级触发,且 ignoreCancelled = true
- AutoHarvest 进行验证:生存模式、世界已启用、玩家已开启、作物成熟、环境有效
- 原版处理破坏过程——处理掉落、抢夺附魔、工具耐久度、统计数据和成就
- 在一刻钟(tick)后,AutoHarvest 将作物放回原位,年龄重置为 0
骨粉路径
- 玩家使用骨粉右键点击作物
- 原版应用骨粉效果——消耗物品、推进生长、播放粒子效果
- 一刻钟后,AutoHarvest 检查作物是否现在已成熟
- 如果成熟:计算掉落物,扣除一个种子(公平性),重新种植,并掉落物品
为什么不使用取消事件 + 手动掉落?
许多农场插件会取消破坏事件并手动计算掉落物。这会导致以下问题:
- mcMMO / Jobs 的经验值钩子(它们读取原版掉落物)
- 统计信息(
CROP_WASTED,方块破坏统计)
- 进度(“有籽之地”等)
- 工具耐久度与附魔处理
- 任何监听
BlockBreakEvent 的下游插件
AutoHarvest 通过让原版完全处理破坏过程来避免上述所有问题。
性能
AutoHarvest 旨在实现零可测量的 TPS 影响。
EnumMap<Material> 作物查找 — O(1),无哈希开销
- 事件处理器中不使用流 — 使用普通循环以利于 JIT 优化的热点路径
- 事件中不重新解析配置 — 使用不可变的
PluginConfig 快照,在重载时原子交换
- 事件处理器中不记录 INFO 级别日志 — 仅限调试门控
- 1 刻定时重种 通过
runTask 实现,而非 runTaskLater(0)
- 兼容 Folia — 当检测到 Folia 时使用
RegionScheduler,在 Paper 上使用标准 BukkitScheduler
基准测试
| 场景 |
目标 |
| 1 万个小麦农场,5 名玩家持续收割 |
19.8+ TPS |
| 骨粉连点(每位玩家每秒点击 10 次 x 4 位玩家) |
19.9+ TPS |
| 插件加载时间 |
< 50ms |
/autoharvest reload |
< 100ms |
兼容性
- Paper 1.21.x (1.21 - 1.21.4+)
- Folia — 启动时检测,使用区域感知调度
- 需要 Java 21
- 保护类插件 — AutoHarvest 尊重
BlockBreakEvent 的取消。任何取消该事件的插件(WorldGuard、GriefPrevention、Towny、Lands、Residence 等)都会阻止受保护区域内的自动收割。无需特殊配置。
- 仅在生存模式中触发 — 忽略创造模式、冒险模式和旁观者模式
安装
- 从 Modrinth 下载 jar 文件
- 放入服务器的
plugins/ 文件夹
- 重启服务器
- 可选:编辑
plugins/AutoHarvest/config.yml 并运行 /autoharvest reload
从源代码构建
需要 Java 21。
git clone https://github.com/yourusername/AutoHarvest.git
cd AutoHarvest
./gradlew build
插件 jar 将位于 build/libs/ 中。
许可证
MIT
AutoHarvest
Vanilla+ auto-harvest and replant for Paper 1.21.x
Break a mature crop and it replants itself. Right-click with bonemeal and it grows, harvests, and replants in one action. No cheats, no duplication, no TPS impact. Just the QoL feature vanilla forgot.
Features
Break Harvesting
Break any mature crop and it drops normally — then replants at growth stage 0 automatically. Vanilla handles the break, drops, tool durability, enchantments, XP, and statistics. AutoHarvest only adds the replant.
Bonemeal Harvesting
Right-click an immature crop with bonemeal. Vanilla advances the growth. If the crop becomes mature from that application, AutoHarvest harvests it, drops the items, and replants — all in one click. One bonemeal consumed per use, exactly like vanilla.
Seed Fairness
The bonemeal path subtracts one seed from drops to prevent duplication. Without this, every bonemeal harvest would create a free seed (the crop is replanted but drops include the replant cost). AutoHarvest enforces net-zero: bonemeal harvesting produces the same drops as manually breaking and replanting.
Per-Player Toggle
/autoharvest toggle — players who want pure vanilla can opt out. State persists across relogs and server restarts via PersistentDataContainer. No database required.
Supported Crops
| Crop |
Replant Age |
Notes |
| Wheat |
0 |
Standard ageable crop |
| Carrots |
0 |
Standard ageable crop |
| Potatoes |
0 |
Poisonous potato drops preserved |
| Beetroot |
0 |
Standard ageable crop |
| Nether Wart |
0 |
Validates soul sand beneath before replanting |
| Cocoa Beans |
0 |
Preserves facing direction, validates jungle log |
| Sweet Berries |
1 |
Matches vanilla right-click harvest feel |
Explicitly Not Supported
- Sugar cane, bamboo, cactus, kelp — vertical growth, dupe risk with pistons
- Melons, pumpkins — stem-based, already effectively auto-replant
- Chorus fruit — not a farm crop
Commands
| Command |
Description |
Permission |
/autoharvest toggle |
Toggle for yourself |
autoharvest.use |
/autoharvest toggle <player> |
Toggle for another player |
autoharvest.admin.toggle-others |
/autoharvest info |
Show status, version, enabled crops |
autoharvest.use |
/autoharvest reload |
Reload configuration |
autoharvest.admin.reload |
Alias: /ah works for all commands.
Permissions
| Permission |
Default |
Description |
autoharvest.use |
true |
Toggle and info commands |
autoharvest.break |
true |
Auto-harvest on crop break |
autoharvest.bonemeal |
true |
Auto-harvest via bonemeal |
autoharvest.admin |
op |
All admin commands |
autoharvest.admin.reload |
op |
Reload configuration |
autoharvest.admin.toggle-others |
op |
Toggle for other players |
Set require-permission: true in config to require autoharvest.use for the plugin to function at all. By default, it works for everyone.
Configuration
All settings in plugins/AutoHarvest/config.yml. Changes take effect with /autoharvest reload — no server restart needed.
general:
default-enabled: true # New players start with auto-harvest on
require-permission: false # Require autoharvest.use permission
enabled-worlds: [] # Empty = all worlds. List specific worlds to restrict.
disabled-worlds: # These worlds are always excluded
- "world_nether"
- "world_the_end"
harvest:
on-break: true # Auto-replant when breaking mature crops
on-bonemeal: true # Harvest + replant when bonemealing to maturity
require-hoe: false # Only trigger when holding a hoe
bonemeal-subtract-replant-cost: true # Fairness: subtract 1 seed from bonemeal drops
drops:
enabled: true # Set false to suppress all drops (adventure maps)
drop-at-center: true # Drop at block center vs exact break location
overflow-to-ground: true # Full inventory? Drop on ground, not void
crops: # Enable/disable individual crop types
wheat: true
carrots: true
potatoes: true
beetroot: true
nether_wart: true
cocoa: true
sweet_berries: true
cooldown:
bonemeal-ms: 50 # Anti-macro: ms between bonemeal harvests per player
feedback:
particles: true # Green sparkle particles on harvest
sound: true # Crop break sound on harvest
sound-name: "block.crop.break"
sound-volume: 0.5
sound-pitch: 1.2
debug: false # Log every harvest with player, location, crop, drops
Messages are customizable in messages.yml using MiniMessage format.
How It Works
AutoHarvest is designed to be invisible to the game engine. It never cancels events or re-implements vanilla mechanics.
Break Path
- Player breaks a mature crop
BlockBreakEvent fires at HIGH priority with ignoreCancelled = true
- AutoHarvest validates: survival mode, world enabled, player toggled on, crop mature, environment valid
- Vanilla processes the break — handles drops, Fortune, tool durability, statistics, advancements
- One tick later, AutoHarvest places the crop back at age 0
Bonemeal Path
- Player right-clicks a crop with bonemeal
- Vanilla applies the bonemeal — consumes item, advances growth, plays particles
- One tick later, AutoHarvest checks if the crop is now mature
- If mature: calculates drops, subtracts one seed (fairness), replants, drops items
Why Not Cancel + Manual Drops?
Many farming plugins cancel the break event and manually calculate drops. This breaks:
- mcMMO / Jobs XP hooks (they read vanilla drops)
- Statistics (
CROP_WASTED, block break stats)
- Advancements ("A Seedy Place", etc.)
- Tool durability and enchantment processing
- Any downstream plugin that listens to
BlockBreakEvent
AutoHarvest avoids all of this by letting vanilla handle the break completely.
Performance
AutoHarvest is built for zero measurable TPS impact.
EnumMap<Material> crop lookup — O(1), no hashing overhead
- No streams in event handlers — plain loops for JIT-friendly hot paths
- No config re-parsing per event — immutable
PluginConfig snapshot, atomically swapped on reload
- No logging in event handlers at INFO level — debug-gated only
- 1-tick scheduled replant via
runTask, not runTaskLater(0)
- Folia compatible — uses
RegionScheduler when Folia is detected, standard BukkitScheduler on Paper
Benchmarks
| Scenario |
Target |
| 10k wheat farm, 5 players harvesting continuously |
19.8+ TPS |
| Bonemeal spam (10 clicks/sec/player x 4 players) |
19.9+ TPS |
| Plugin load time |
< 50ms |
/autoharvest reload |
< 100ms |
Compatibility
- Paper 1.21.x (1.21 - 1.21.4+)
- Folia — detected at startup, uses region-aware scheduling
- Java 21 required
- Protection plugins — AutoHarvest respects
BlockBreakEvent cancellation. Any plugin that cancels the event (WorldGuard, GriefPrevention, Towny, Lands, Residence, etc.) will prevent auto-harvest in protected regions. No special configuration needed.
- Only fires in Survival mode — Creative, Adventure, and Spectator are ignored
Installation
- Download the jar from Modrinth
- Place in your server's
plugins/ folder
- Restart the server
- Optionally edit
plugins/AutoHarvest/config.yml and run /autoharvest reload
Building from Source
Requires Java 21.
git clone https://github.com/yourusername/AutoHarvest.git
cd AutoHarvest
./gradlew build
The plugin jar will be in build/libs/.
License
MIT
评论 0
登录后参与评分
还没有评论,来抢沙发吧