Skip to content

Commit

Permalink
= Auto Pest Hunter - bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
onixiya1337 committed Jan 23, 2024
1 parent 902c088 commit 6f465f2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ baseGroup=com.jelly.farmhelperv2
mcVersion=1.8.9
modid=farmhelperv2
modName=FarmHelper
version=2.4.4-pre3
shouldRelease=false
version=2.4.4-pre4
shouldRelease=true
13 changes: 11 additions & 2 deletions src/main/java/com/jelly/farmhelperv2/config/FarmHelperConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -1166,16 +1166,21 @@ public static void triggerManuallyPestsDestroyer() {
description = "Pauses the Auto Pest Hunter during Jacob's contests"
)
public static boolean pauseAutoPestHunterDuringJacobsContest = true;
@Switch(
name = "Ignore Jacob's Contest", category = AUTO_PEST_HUNTER, subcategory = "Auto Pest Hunter",
description = "Start the Auto Pest Hunter regardless of the next Jacob's contests"
)
public static boolean autoPestHunterIgnoreJacobsContest = false;
@Slider(
name = "Trigger before contest starts (in minutes)", category = AUTO_PEST_HUNTER, subcategory = "Auto Pest Hunter",
description = "The time before the contest starts to trigger the auto pest hunter",
min = 5, max = 25
min = 1, max = 40
)
public static int autoPestHunterTriggerBeforeContestStarts = 5;
@Slider(
name = "Pests amount required", category = AUTO_PEST_HUNTER, subcategory = "Auto Pest Hunter",
description = "The amount of pests in a vacuum required to start the auto pest hunter",
min = 5, max = 200
min = 1, max = 40
)
public static int autoPestHunterMinPests = 10;
@Switch(
Expand Down Expand Up @@ -1853,8 +1858,12 @@ public FarmHelperConfig() {
this.addDependency("pingEveryoneOnPestsDetectionNumberExceeded", "enableWebHook");

this.addDependency("pauseAutoPestHunterDuringJacobsContest", "autoPestHunter");
this.addDependency("autoPestHunterIgnoreJacobsContest", "autoPestHunter");
this.addDependency("autoPestHunterTriggerBeforeContestStarts", "autoPestHunter");
this.addDependency("autoPestHunterMinPests", "autoPestHunter");
this.addDependency("logAutoPestHunterEvents", "autoPestHunter");
this.addDependency("autoPestHunterTriggerBeforeContestStarts",
"You can either wait until Jacob's Contest or run it regardless.", () -> !autoPestHunterIgnoreJacobsContest);
this.hideIf("pestHunterDeskX", () -> true);
this.hideIf("pestHunterDeskY", () -> true);
this.hideIf("pestHunterDeskZ", () -> true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
import org.jetbrains.annotations.Nullable;

import java.awt.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.regex.Matcher;

public class AutoPestHunter implements IFeature {
Expand All @@ -50,6 +52,7 @@ public static AutoPestHunter getInstance() {
private final Clock stuckClock = new Clock();
@Getter
private final Clock delayClock = new Clock();
private final Clock delayToggle = new Clock();
private BlockPos positionBeforeTp;
private int finishTries = 0;
private final BlockPos initialDeskPos = new BlockPos(-24, 71, -7);
Expand Down Expand Up @@ -156,7 +159,16 @@ public boolean canEnableMacro(boolean manual) {
LogUtils.sendDebug("[Auto Pest Hunter] Jacob's contest is active, skipping...");
return false;
}
if (!manual && GameStateHandler.getInstance().inJacobContest()) {
List<String> tabList = TablistUtils.getTabList();
if (tabList.size() < 2)
return false;
for (String line : tabList) {
if (line.contains("Pesthunter Bonus:")) {
LogUtils.sendDebug("[Auto Pest Hunter] Pesthunter bonus is active, skipping...");
return false;
}
}
if (!manual && GameStateHandler.getInstance().inJacobContest() && !FarmHelperConfig.autoPestHunterIgnoreJacobsContest) {
for (String line : TablistUtils.getTabList()) {
Matcher matcher = GameStateHandler.getInstance().jacobsRemainingTimePattern.matcher(line);
if (matcher.find()) {
Expand All @@ -168,7 +180,7 @@ public boolean canEnableMacro(boolean manual) {
}
}
}
if (!manual && FarmHelperConfig.autoPestHunterMinPests > 0 && GameStateHandler.getInstance().getPestsFromVacuum() < FarmHelperConfig.autoPestHunterMinPests) {
if (!manual && GameStateHandler.getInstance().getPestsFromVacuum() < FarmHelperConfig.autoPestHunterMinPests) {
LogUtils.sendDebug("[Auto Pest Hunter] There are not enough pests to start the macro!");
return false;
}
Expand Down Expand Up @@ -370,8 +382,8 @@ public void onTickExecution(TickEvent.ClientTickEvent event) {
state = State.WAIT_FOR_VACUUM;
} else {
if (FarmHelperConfig.logAutoPestHunterEvents)
LogUtils.webhookLog("[Auto Pest Hunter] Failed to empty your vacuum because it's empty!");
LogUtils.sendError("[Auto Pest Hunter] The vacuum is empty!");
LogUtils.webhookLog("[Auto Pest Hunter] Failed to empty your vacuum!");
LogUtils.sendError("[Auto Pest Hunter] Failed to empty your vacuum!");
state = State.GO_BACK;
}
InventoryUtils.clickContainerSlot(vacuumSlot.slotNumber, InventoryUtils.ClickType.LEFT, InventoryUtils.ClickMode.PICKUP);
Expand Down

0 comments on commit 6f465f2

Please sign in to comment.