Skip to content

Commit fffafe7

Browse files
Add GlowBerryPlantType
1 parent cd41607 commit fffafe7

File tree

2 files changed

+74
-3
lines changed

2 files changed

+74
-3
lines changed

src/main/java/net/wurstclient/hacks/autofarm/AutoFarmPlantTypeManager.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public final class AutoFarmPlantTypeManager
2424
public final CactusPlantType cactusType = new CactusPlantType();
2525
public final CarrotsPlantType carrotsType = new CarrotsPlantType();
2626
public final CocoaBeanPlantType cocoaBeanType = new CocoaBeanPlantType();
27+
public final GlowBerryPlantType glowBerryType = new GlowBerryPlantType();
2728
public final KelpPlantType kelpType = new KelpPlantType();
2829
public final MelonPlantType melonType = new MelonPlantType();
2930
public final NetherWartPlantType netherWartType = new NetherWartPlantType();
@@ -40,9 +41,9 @@ public final class AutoFarmPlantTypeManager
4041

4142
public final List<AutoFarmPlantType> plantTypes =
4243
List.of(amethystType, bambooType, beetrootsType, cactusType,
43-
carrotsType, cocoaBeanType, kelpType, melonType, netherWartType,
44-
pitcherPlantType, potatoesType, pumpkinType, sugarCaneType,
45-
sweetBerryPlantType, torchflowerType, wheatType);
44+
carrotsType, cocoaBeanType, glowBerryType, kelpType, melonType,
45+
netherWartType, pitcherPlantType, potatoesType, pumpkinType,
46+
sugarCaneType, sweetBerryPlantType, torchflowerType, wheatType);
4647

4748
public AutoFarmPlantType getReplantingSpotType(BlockPos pos)
4849
{
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright (c) 2014-2025 Wurst-Imperium and contributors.
3+
*
4+
* This source code is subject to the terms of the GNU General Public
5+
* License, version 3. If a copy of the GPL was not distributed with this
6+
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
7+
*/
8+
package net.wurstclient.hacks.autofarm.plants;
9+
10+
import net.minecraft.block.BlockState;
11+
import net.minecraft.block.CaveVines;
12+
import net.minecraft.item.Item;
13+
import net.minecraft.item.Items;
14+
import net.minecraft.util.math.BlockPos;
15+
import net.minecraft.util.math.Direction;
16+
import net.wurstclient.WurstClient;
17+
import net.wurstclient.hacks.autofarm.AutoFarmPlantType;
18+
import net.wurstclient.settings.CheckboxSetting;
19+
import net.wurstclient.util.BlockUtils;
20+
21+
public final class GlowBerryPlantType extends AutoFarmPlantType
22+
{
23+
@Override
24+
public final boolean isReplantingSpot(BlockPos pos, BlockState state)
25+
{
26+
return state.getBlock() instanceof CaveVines && hasPlantingSurface(pos);
27+
}
28+
29+
@Override
30+
public final boolean hasPlantingSurface(BlockPos pos)
31+
{
32+
BlockState ceiling = BlockUtils.getState(pos.up());
33+
return !(ceiling.getBlock() instanceof CaveVines) && ceiling
34+
.isSideSolidFullSquare(WurstClient.MC.world, pos, Direction.DOWN);
35+
}
36+
37+
@Override
38+
public Item getSeedItem()
39+
{
40+
return Items.GLOW_BERRIES;
41+
}
42+
43+
@Override
44+
public boolean shouldHarvestByInteracting(BlockPos pos, BlockState state)
45+
{
46+
// Right-click-harvest the top-most part so we don't have to replant it.
47+
return state.getBlock() instanceof CaveVines
48+
&& CaveVines.hasBerries(state) && isReplantingSpot(pos, state);
49+
}
50+
51+
@Override
52+
public boolean shouldHarvestByMining(BlockPos pos, BlockState state)
53+
{
54+
// Left-click-harvest any other part so it can grow more berries.
55+
return state.getBlock() instanceof CaveVines
56+
&& !isReplantingSpot(pos, state);
57+
}
58+
59+
@Override
60+
protected CheckboxSetting createHarvestSetting()
61+
{
62+
return new CheckboxSetting("Harvest glow berries", true);
63+
}
64+
65+
@Override
66+
protected CheckboxSetting createReplantSetting()
67+
{
68+
return new CheckboxSetting("Replant glow berries", true);
69+
}
70+
}

0 commit comments

Comments
 (0)