BlueGit

timfa copperfarmer

Harvest torchflowers only at the flower stage.

Torchflower_crop max age is an immature middle stage; wait for the torchflower block and replant as crop age 0.

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

timfa Tim Falken · pushed by timfa

Authored 2026-08-15 · 3 months ago

Hash
5e8b6610eff07485fde4cb964c950f8ab1ffec1d
Parent
11b49e13
6 files changed +19 −7
README.md +1 −1
@@ -1,4 +1,4 @@
1 # CopperFarmer 0.1.10
1 # CopperFarmer 0.1.11
2 2
3 3 First-version Paper 26.2 / Java 25 plugin for autonomous Copper Farmer Golems.
4 4
@@ -1,4 +1,4 @@
1# CopperFarmer 0.1.10
1# CopperFarmer 0.1.11
2
2
3First-version Paper 26.2 / Java 25 plugin for autonomous Copper Farmer Golems.
3First-version Paper 26.2 / Java 25 plugin for autonomous Copper Farmer Golems.
4
4
TESTING.md +2 −2
@@ -1,4 +1,4 @@
1 # CopperFarmer 0.1.10 smoke test
1 # CopperFarmer 0.1.11 smoke test
2 2
3 3 Use this checklist on a Paper 26.2 server before treating 0.1.0 as production-ready.
4 4
@@ -37,7 +37,7 @@ Test at least one full harvest/replant/deposit cycle for:
37 37 - [ ] Nether Wart
38 38 - [ ] Cocoa
39 39 - [ ] Sweet Berry Bushes
40 - [ ] Torchflowers
40 - [ ] Torchflowers (only the flower block is harvested; age-1 crop is left alone)
41 41 - [ ] Melon (fruit breaks; attached stem survives)
42 42 - [ ] Pumpkin (fruit breaks; attached stem survives)
43 43
@@ -1,4 +1,4 @@
1# CopperFarmer 0.1.10 smoke test
1# CopperFarmer 0.1.11 smoke test
2
2
3Use this checklist on a Paper 26.2 server before treating 0.1.0 as production-ready.
3Use this checklist on a Paper 26.2 server before treating 0.1.0 as production-ready.
4
4
@@ -37,7 +37,7 @@ Test at least one full harvest/replant/deposit cycle for:
37- [ ] Nether Wart
37- [ ] Nether Wart
38- [ ] Cocoa
38- [ ] Cocoa
39- [ ] Sweet Berry Bushes
39- [ ] Sweet Berry Bushes
40- [ ] Torchflowers
40- [ ] Torchflowers (only the flower block is harvested; age-1 crop is left alone)
41- [ ] Melon (fruit breaks; attached stem survives)
41- [ ] Melon (fruit breaks; attached stem survives)
42- [ ] Pumpkin (fruit breaks; attached stem survives)
42- [ ] Pumpkin (fruit breaks; attached stem survives)
43
43
build.gradle.kts +1 −1
@@ -3,7 +3,7 @@ plugins {
3 3 }
4 4
5 5 group = "nl.timfalken"
6 version = "0.1.10"
6 version = "0.1.11"
7 7
8 8 repositories {
9 9 mavenCentral()
@@ -3,7 +3,7 @@ plugins {
3}
3}
4
4
5group = "nl.timfalken"
5group = "nl.timfalken"
6version = "0.1.10"
6version = "0.1.11"
7
7
8repositories {
8repositories {
9 mavenCentral()
9 mavenCentral()
src/main/java/nl/timfalken/copperfarmer/CopperFarmerPlugin.java +1 −1
@@ -48,7 +48,7 @@ public final class CopperFarmerPlugin extends JavaPlugin {
48 48 long interval = Math.max(1L, getConfig().getLong("brain-tick-interval", 5L));
49 49 brainTask = getServer().getScheduler().runTaskTimer(this, () -> manager.tick(interval), interval, interval);
50 50
51 getLogger().info("CopperFarmer 0.1.10 enabled for Paper 26.2.");
51 getLogger().info("CopperFarmer 0.1.11 enabled for Paper 26.2.");
52 52 }
53 53
54 54 @Override
@@ -48,7 +48,7 @@ public final class CopperFarmerPlugin extends JavaPlugin {
48 long interval = Math.max(1L, getConfig().getLong("brain-tick-interval", 5L));
48 long interval = Math.max(1L, getConfig().getLong("brain-tick-interval", 5L));
49 brainTask = getServer().getScheduler().runTaskTimer(this, () -> manager.tick(interval), interval, interval);
49 brainTask = getServer().getScheduler().runTaskTimer(this, () -> manager.tick(interval), interval, interval);
50
50
51 getLogger().info("CopperFarmer 0.1.10 enabled for Paper 26.2.");
51 getLogger().info("CopperFarmer 0.1.11 enabled for Paper 26.2.");
52 }
52 }
53
53
54 @Override
54 @Override
src/main/java/nl/timfalken/copperfarmer/CropRegistry.java +13 −1
@@ -43,7 +43,8 @@ final class CropRegistry {
43 43 register(Material.NETHER_WART, Material.NETHER_WART, PlantSupport.SOUL_SAND, false);
44 44 register(Material.COCOA, Material.COCOA_BEANS, PlantSupport.JUNGLE_LOG_SIDE, false);
45 45 register(Material.SWEET_BERRY_BUSH, Material.SWEET_BERRIES, PlantSupport.NONE, false);
46 register(Material.TORCHFLOWER_CROP, Material.TORCHFLOWER_SEEDS, PlantSupport.FARMLAND, false);
46 // Torchflower_crop ages 0–1 are immature; the final stage is the torchflower flower block.
47 register(Material.TORCHFLOWER, Material.TORCHFLOWER_SEEDS, PlantSupport.FARMLAND, false);
47 48 register(Material.MELON, Material.MELON_SEEDS, PlantSupport.NONE, true);
48 49 register(Material.PUMPKIN, Material.PUMPKIN_SEEDS, PlantSupport.NONE, true);
49 50 }
@@ -76,6 +77,9 @@ final class CropRegistry {
76 77 : Material.ATTACHED_PUMPKIN_STEM);
77 78 }
78 79
80 // Fully grown torchflowers are the flower block, not an Ageable crop stage.
81 if (block.getType() == Material.TORCHFLOWER) return true;
82
79 83 if (block.getBlockData() instanceof Ageable ageable) {
80 84 return ageable.getAge() >= ageable.getMaximumAge();
81 85 }
@@ -100,17 +104,25 @@ final class CropRegistry {
100 104 cocoa.setAge(0);
101 105 return cocoa;
102 106 }
107 if (crop.block() == Material.TORCHFLOWER) return torchflowerCropData();
103 108 BlockData data = crop.block().createBlockData();
104 109 if (data instanceof Ageable ageable) ageable.setAge(0);
105 110 return data;
106 111 }
107 112
108 113 BlockData replantData(BlockData harvested) {
114 if (harvested.getMaterial() == Material.TORCHFLOWER) return torchflowerCropData();
109 115 BlockData data = harvested.clone();
110 116 if (data instanceof Ageable ageable) ageable.setAge(0);
111 117 return data;
112 118 }
113 119
120 private static BlockData torchflowerCropData() {
121 BlockData data = Material.TORCHFLOWER_CROP.createBlockData();
122 if (data instanceof Ageable ageable) ageable.setAge(0);
123 return data;
124 }
125
114 126 boolean isCocoaSupport(Material material) {
115 127 return material == Material.JUNGLE_LOG
116 128 || material == Material.JUNGLE_WOOD
@@ -43,7 +43,8 @@ final class CropRegistry {
43 register(Material.NETHER_WART, Material.NETHER_WART, PlantSupport.SOUL_SAND, false);
43 register(Material.NETHER_WART, Material.NETHER_WART, PlantSupport.SOUL_SAND, false);
44 register(Material.COCOA, Material.COCOA_BEANS, PlantSupport.JUNGLE_LOG_SIDE, false);
44 register(Material.COCOA, Material.COCOA_BEANS, PlantSupport.JUNGLE_LOG_SIDE, false);
45 register(Material.SWEET_BERRY_BUSH, Material.SWEET_BERRIES, PlantSupport.NONE, false);
45 register(Material.SWEET_BERRY_BUSH, Material.SWEET_BERRIES, PlantSupport.NONE, false);
46 register(Material.TORCHFLOWER_CROP, Material.TORCHFLOWER_SEEDS, PlantSupport.FARMLAND, false);
46 // Torchflower_crop ages 0–1 are immature; the final stage is the torchflower flower block.
47 register(Material.TORCHFLOWER, Material.TORCHFLOWER_SEEDS, PlantSupport.FARMLAND, false);
47 register(Material.MELON, Material.MELON_SEEDS, PlantSupport.NONE, true);
48 register(Material.MELON, Material.MELON_SEEDS, PlantSupport.NONE, true);
48 register(Material.PUMPKIN, Material.PUMPKIN_SEEDS, PlantSupport.NONE, true);
49 register(Material.PUMPKIN, Material.PUMPKIN_SEEDS, PlantSupport.NONE, true);
49 }
50 }
@@ -76,6 +77,9 @@ final class CropRegistry {
76 : Material.ATTACHED_PUMPKIN_STEM);
77 : Material.ATTACHED_PUMPKIN_STEM);
77 }
78 }
78
79
80 // Fully grown torchflowers are the flower block, not an Ageable crop stage.
81 if (block.getType() == Material.TORCHFLOWER) return true;
82
79 if (block.getBlockData() instanceof Ageable ageable) {
83 if (block.getBlockData() instanceof Ageable ageable) {
80 return ageable.getAge() >= ageable.getMaximumAge();
84 return ageable.getAge() >= ageable.getMaximumAge();
81 }
85 }
@@ -100,17 +104,25 @@ final class CropRegistry {
100 cocoa.setAge(0);
104 cocoa.setAge(0);
101 return cocoa;
105 return cocoa;
102 }
106 }
107 if (crop.block() == Material.TORCHFLOWER) return torchflowerCropData();
103 BlockData data = crop.block().createBlockData();
108 BlockData data = crop.block().createBlockData();
104 if (data instanceof Ageable ageable) ageable.setAge(0);
109 if (data instanceof Ageable ageable) ageable.setAge(0);
105 return data;
110 return data;
106 }
111 }
107
112
108 BlockData replantData(BlockData harvested) {
113 BlockData replantData(BlockData harvested) {
114 if (harvested.getMaterial() == Material.TORCHFLOWER) return torchflowerCropData();
109 BlockData data = harvested.clone();
115 BlockData data = harvested.clone();
110 if (data instanceof Ageable ageable) ageable.setAge(0);
116 if (data instanceof Ageable ageable) ageable.setAge(0);
111 return data;
117 return data;
112 }
118 }
113
119
120 private static BlockData torchflowerCropData() {
121 BlockData data = Material.TORCHFLOWER_CROP.createBlockData();
122 if (data instanceof Ageable ageable) ageable.setAge(0);
123 return data;
124 }
125
114 boolean isCocoaSupport(Material material) {
126 boolean isCocoaSupport(Material material) {
115 return material == Material.JUNGLE_LOG
127 return material == Material.JUNGLE_LOG
116 || material == Material.JUNGLE_WOOD
128 || material == Material.JUNGLE_WOOD
src/main/resources/plugin.yml +1 −1
@@ -1,5 +1,5 @@
1 1 name: CopperFarmer
2 version: 0.1.10
2 version: 0.1.11
3 3 main: nl.timfalken.copperfarmer.CopperFarmerPlugin
4 4 api-version: '26.2'
5 5 author: Tim Falken
@@ -1,5 +1,5 @@
1name: CopperFarmer
1name: CopperFarmer
2version: 0.1.10
2version: 0.1.11
3main: nl.timfalken.copperfarmer.CopperFarmerPlugin
3main: nl.timfalken.copperfarmer.CopperFarmerPlugin
4api-version: '26.2'
4api-version: '26.2'
5author: Tim Falken
5author: Tim Falken