Skip to content

Commit dcb5f20

Browse files
Add settings for AutoFarm rendering
Fixes https://wurstforum.net/d/628
1 parent ece6cdc commit dcb5f20

File tree

2 files changed

+37
-12
lines changed

2 files changed

+37
-12
lines changed

src/main/java/net/wurstclient/hacks/AutoFarmHack.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public AutoFarmHack()
7777
addSetting(checkLOS);
7878
addSetting(faceTarget);
7979
addSetting(swingHand);
80+
renderer.getSettings().forEach(this::addSetting);
8081
plantTypes.getSettings().forEach(this::addSetting);
8182
}
8283

@@ -170,15 +171,17 @@ public void onUpdate()
170171

171172
List<BlockPos> blocksToHarvest = Stream
172173
.of(blocksToMine, blocksToInteract).flatMap(List::stream).toList();
173-
renderer.update(blocksToHarvest, replantingSpots.keySet(),
174+
renderer.update(replantingSpots.keySet(), blocksToHarvest,
174175
blocksToReplant);
175176
}
176177

177178
@Override
178179
public void onRender(MatrixStack matrixStack, float partialTicks)
179180
{
180181
renderer.render(matrixStack);
181-
overlay.render(matrixStack, partialTicks, currentlyMining);
182+
183+
if(renderer.drawBlocksToHarvest.isChecked())
184+
overlay.render(matrixStack, partialTicks, currentlyMining);
182185
}
183186

184187
/**

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

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99

1010
import java.util.Collection;
1111
import java.util.List;
12+
import java.util.stream.Stream;
1213

1314
import net.minecraft.client.util.math.MatrixStack;
1415
import net.minecraft.util.math.BlockPos;
1516
import net.minecraft.util.math.Box;
17+
import net.wurstclient.settings.CheckboxSetting;
18+
import net.wurstclient.settings.Setting;
1619
import net.wurstclient.util.RenderUtils;
1720

1821
public final class AutoFarmRenderer
@@ -21,28 +24,47 @@ public final class AutoFarmRenderer
2124
new Box(BlockPos.ORIGIN).contract(1 / 16.0);
2225
private static final Box NODE_BOX = new Box(BlockPos.ORIGIN).contract(0.25);
2326

24-
private List<Box> blocksToHarvest = List.of();
27+
public final CheckboxSetting drawReplantingSpots =
28+
new CheckboxSetting("Draw replanting spots", true);
29+
public final CheckboxSetting drawBlocksToHarvest =
30+
new CheckboxSetting("Draw blocks to harvest", true);
31+
public final CheckboxSetting drawBlocksToReplant =
32+
new CheckboxSetting("Draw blocks to replant", true);
33+
2534
private List<Box> replantingSpots = List.of();
35+
private List<Box> blocksToHarvest = List.of();
2636
private List<Box> blocksToReplant = List.of();
2737

28-
public void update(Collection<BlockPos> blocksToHarvest,
29-
Collection<BlockPos> replantingSpots,
38+
public void update(Collection<BlockPos> replantingSpots,
39+
Collection<BlockPos> blocksToHarvest,
3040
Collection<BlockPos> blocksToReplant)
3141
{
32-
this.blocksToHarvest =
33-
blocksToHarvest.stream().map(BLOCK_BOX::offset).toList();
3442
this.replantingSpots =
3543
replantingSpots.stream().map(NODE_BOX::offset).toList();
44+
this.blocksToHarvest =
45+
blocksToHarvest.stream().map(BLOCK_BOX::offset).toList();
3646
this.blocksToReplant =
3747
blocksToReplant.stream().map(BLOCK_BOX::offset).toList();
3848
}
3949

4050
public void render(MatrixStack matrixStack)
4151
{
42-
RenderUtils.drawOutlinedBoxes(matrixStack, blocksToHarvest, 0x8000FF00,
43-
false);
44-
RenderUtils.drawNodes(matrixStack, replantingSpots, 0x8000FFFF, false);
45-
RenderUtils.drawOutlinedBoxes(matrixStack, blocksToReplant, 0x80FF0000,
46-
false);
52+
if(drawReplantingSpots.isChecked())
53+
RenderUtils.drawNodes(matrixStack, replantingSpots, 0x8000FFFF,
54+
false);
55+
56+
if(drawBlocksToHarvest.isChecked())
57+
RenderUtils.drawOutlinedBoxes(matrixStack, blocksToHarvest,
58+
0x8000FF00, false);
59+
60+
if(drawBlocksToReplant.isChecked())
61+
RenderUtils.drawOutlinedBoxes(matrixStack, blocksToReplant,
62+
0x80FF0000, false);
63+
}
64+
65+
public Stream<Setting> getSettings()
66+
{
67+
return Stream.of(drawReplantingSpots, drawBlocksToHarvest,
68+
drawBlocksToReplant);
4769
}
4870
}

0 commit comments

Comments
 (0)