Skip to content

Commit

Permalink
Pests Destroyer:
Browse files Browse the repository at this point in the history
 = TP Fixes

Auto Sell:
 + Added Pests Vinyl to config

Fixed Profit Calculator showing 100's of millions because of bountiful reforge

Visitors Macro:
 = Fixes and tweaks
  • Loading branch information
May2Beez committed Mar 15, 2024
1 parent 00227d6 commit 363b16a
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 80 deletions.
2 changes: 1 addition & 1 deletion 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.5.0-pre3
version=2.5.0-pre4
shouldRelease=true
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,9 @@ public static void triggerManuallyAutoPestHunter() {
@Switch(name = "Iron Hoe", category = AUTO_SELL, subcategory = "Customize items sold to NPC")
public static boolean autoSellIronHoe = true;

@Switch(name = "Pest Vinyls", category = AUTO_SELL, subcategory = "Customize items sold to NPC")
public static boolean autoSellPestVinyls = true;

@Text(
name = "Custom Items", category = AUTO_SELL, subcategory = "Customize items sold to NPC",
description = "Add custom items to AutoSell here. Use | to split the messages.",
Expand Down Expand Up @@ -1608,7 +1611,7 @@ public enum SPRAYONATOR_ITEM {
@Slider(
name = "Time between changing rows", category = DELAYS, subcategory = "Changing rows",
description = "The minimum time to wait before changing rows (in milliseconds)",
min = 70, max = 2000
min = 80, max = 2000
)
public static float timeBetweenChangingRows = 400f;
@Slider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ private boolean shouldSellCustomItem(String name) {
if (FarmHelperConfig.autoSellRunes && name.contains(" Rune") && !name.contains("Music")) return true;
if (FarmHelperConfig.autoSellDeadBush && name.contains("Dead Bush")) return true;
if (FarmHelperConfig.autoSellIronHoe && name.contains("Iron Hoe")) return true;
if (FarmHelperConfig.autoSellPestVinyls && name.contains("Vinyl")) return true;
if (!FarmHelperConfig.autoSellCustomItems.isEmpty()) {
List<String> customItems = Arrays.asList(FarmHelperConfig.autoSellCustomItems.split("\\|"));
return customItems.stream().anyMatch(item -> StringUtils.stripControlCodes(name.toLowerCase()).contains(item.toLowerCase()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public class PestsDestroyer implements IFeature {

private boolean gotRangeOfVacuum = false;
private boolean isPlotObstructed = false;
private long lastKillTimestamp = 0;

private final List<Integer> killedPestsFrom = new ArrayList<>();

Expand Down Expand Up @@ -132,6 +133,7 @@ public void start() {
gotRangeOfVacuum = false;
isPlotObstructed = false;
preparing = true;
lastKillTimestamp = 0;
if (MacroHandler.getInstance().isMacroToggled()) {
MacroHandler.getInstance().pauseMacro();
MacroHandler.getInstance().getCurrentMacro().ifPresent(am -> am.setSavedState(Optional.empty()));
Expand Down Expand Up @@ -546,11 +548,10 @@ public void onTickExecute(TickEvent.ClientTickEvent event) {
double distance = Math.sqrt(mc.thePlayer.getDistanceSq(PlotUtils.getPlotCenter(closestPlot.number)));

this.closestPlot = Optional.of(closestPlot);
if (distance > 80 && !isPlotObstructed) {
if (distance > 150 && !isPlotObstructed) {
state = States.TELEPORT_TO_PLOT;
} else {
state = States.FLY_TO_THE_CLOSEST_PLOT;
isPlotObstructed = false;
}
delayClock.schedule((long) (500 + Math.random() * 500));
break;
Expand Down Expand Up @@ -857,11 +858,13 @@ public void onTickExecute(TickEvent.ClientTickEvent event) {
break;
case CHECK_ANOTHER_PEST:
LogUtils.sendDebug(GameStateHandler.getInstance().getPestsCount() + " pest" + (GameStateHandler.getInstance().getPestsCount() == 1 ? "" : "s") + " left");
if (GameStateHandler.getInstance().getCurrentPlotPestsCount() == 0 && GameStateHandler.getInstance().getPestsCount() <= 1 || GameStateHandler.getInstance().getPestsCount() == 0) {
if (GameStateHandler.getInstance().getPestsCount() == 0 ||
(GameStateHandler.getInstance().getPestsCount() == 1 && GameStateHandler.getInstance().getCurrentPlotPestsCount() == 1 && System.currentTimeMillis() - lastKillTimestamp < 1_000)) {
state = States.GO_BACK;
delayClock.schedule((long) (500 + Math.random() * 500));
break;
}
isPlotObstructed = false;
Entity closestPest2 = getClosestPest();
KeyBindUtils.stopMovement();
if (closestPest2 != null) {
Expand All @@ -874,7 +877,7 @@ public void onTickExecute(TickEvent.ClientTickEvent event) {
if (plotOpt != null) {
double distanceToPlot = Math.sqrt(mc.thePlayer.getDistanceSqToCenter(PlotUtils.getPlotCenter(plotOpt.number)));
LogUtils.sendDebug("Distance to plot: " + distanceToPlot);
if (distanceToPlot < 100 || isPlotObstructed) {
if (distanceToPlot < 150) {
LogUtils.sendDebug("Going manually to another plot");
state = States.GET_CLOSEST_PLOT;
delayClock.schedule(300 + (long) (Math.random() * 250));
Expand Down Expand Up @@ -1128,6 +1131,7 @@ public void onEntityDeath(LivingDeathEvent event) {
FlyPathFinderExecutor.getInstance().stop();
lastFireworkLocation = Optional.empty();
lastFireworkTime = 0;
lastKillTimestamp = System.currentTimeMillis();
currentEntityTarget.ifPresent(e -> {
if (!e.equals(event.entity)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public class ProfitCalculator implements IFeature {
private final Pattern regex = Pattern.compile("Dicer dropped (\\d+)x ([\\w\\s]+)!");
public double realProfit = 0;
public double realHourlyProfit = 0;
public double bountifulProfit = 0;
@Getter
private double bountifulProfit = 0;
public double blocksBroken = 0;
private long previousCultivating = 0;

Expand Down Expand Up @@ -210,6 +211,7 @@ public void resetProfits() {
bountifulProfit = 0;
blocksBroken = 0;
previousCultivating = 0;
previousCurrentPurse = 0;
cropsToCount.forEach(crop -> crop.currentAmount = 0);
rngDropToCount.forEach(drop -> drop.currentAmount = 0);
LowerAvgBpsFailsafe.getInstance().resetStates();
Expand Down Expand Up @@ -279,6 +281,8 @@ public void onTickUpdateProfit(TickEvent.ClientTickEvent event) {
}
}

private double previousCurrentPurse = 0;

@SubscribeEvent(priority = EventPriority.LOW)
public void onScoreboardUpdate(UpdateScoreboardLineEvent event) {
if (!MacroHandler.getInstance().isMacroToggled()) return;
Expand All @@ -287,9 +291,11 @@ public void onScoreboardUpdate(UpdateScoreboardLineEvent event) {

ItemStack currentItem = mc.thePlayer.getHeldItem();
if (currentItem != null && StringUtils.stripControlCodes(currentItem.getDisplayName()).startsWith("Bountiful")) {
if (GameStateHandler.getInstance().getCurrentPurse() == previousCurrentPurse) return;
double value = GameStateHandler.getInstance().getCurrentPurse() - GameStateHandler.getInstance().getPreviousPurse();
if (value > 0)
bountifulProfit += value;
previousCurrentPurse = GameStateHandler.getInstance().getCurrentPurse();
}
}

Expand Down
Loading

0 comments on commit 363b16a

Please sign in to comment.