Skip to content

Commit

Permalink
Auto Cookie/God Pot/Repellent:
Browse files Browse the repository at this point in the history
 = Tweaks

Auto Update:
 = Fixed issue of wrong directory sometimes

Fly pathfinder:
 + Added usage of aote/aotv right click

Macro Handler:
 = Fixed issue of resuming scheduler after PDOTT

Pests Destroyer:
 - Reverted changed to suffocating detection
 + Added 'Dont tp to plots' for Melonkingde's farm users

Mushroom Macro:
 = Fixed rare rotation issues

Status HUD:
 = Fixed scaling issue

Teleport Failsafe:
 = Should trigger less often for lag backs

Visitors Macro:
 = Few tweaks
  • Loading branch information
May2Beez committed Apr 27, 2024
1 parent 4e96e83 commit 5f188d9
Show file tree
Hide file tree
Showing 23 changed files with 168 additions and 739 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.6.4
version=2.6.5
shouldRelease=true
8 changes: 8 additions & 0 deletions src/main/java/com/jelly/farmhelperv2/FarmHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.lwjgl.opengl.Display;

import java.io.File;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
Expand All @@ -43,6 +45,12 @@ public class FarmHelper {
public static boolean sentInfoAboutShittyClient = false;
public static boolean isDebug = false;
private final Minecraft mc = Minecraft.getMinecraft();
public static File jarFile = null;

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
jarFile = event.getSourceFile();
}

@Mod.EventHandler
public void init(FMLInitializationEvent event) {
Expand Down
53 changes: 18 additions & 35 deletions src/main/java/com/jelly/farmhelperv2/config/FarmHelperConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.jelly.farmhelperv2.config.page.FailsafeNotificationsPage;
import com.jelly.farmhelperv2.config.struct.Rewarp;
import com.jelly.farmhelperv2.failsafe.FailsafeManager;
import com.jelly.farmhelperv2.failsafe.impl.EvacuateFailsafe;
import com.jelly.farmhelperv2.failsafe.impl.LowerAvgBpsFailsafe;
import com.jelly.farmhelperv2.feature.impl.*;
import com.jelly.farmhelperv2.handler.GameStateHandler;
Expand Down Expand Up @@ -70,6 +71,13 @@ public class FarmHelperConfig extends Config {
//</editor-fold>

//<editor-fold desc="GENERAL">
@Info(
text = "Remember! In any gui related features, such as Auto God Pot, Auto Cookie, Auto Repellent, don't lock hotbar slot 7",
category = GENERAL,
type = InfoType.INFO
)
public static boolean guiInfo;

@Dropdown(
name = "Macro Type", category = GENERAL,
description = "Farm Types",
Expand Down Expand Up @@ -1079,6 +1087,12 @@ else if (testFailsafeTypeSelected != 6)
)
public static boolean sprintWhileFlying = false;

@Switch(
name = "Don't teleport to plots", category = PESTS_DESTROYER, subcategory = "Pests Destroyer",
description = "Prevents the macro from teleporting to plots"
)
public static boolean dontTeleportToPlots = false;

@Switch(
name = "Fly Pathfinder Oringo Compatible",
description = "Makes the fly pathfinder compatible with Oringo, but worse, zzz...",
Expand Down Expand Up @@ -1875,42 +1889,11 @@ public enum SPRAYONATOR_ITEM {
public static boolean autoSwitchTool = true;
//</editor-fold>

//<editor-fold desc="Fly Path Finder">
@Slider(
name = "Allowed Overshoot Threshold", category = EXPERIMENTAL, subcategory = "Flight",
description = "The minimum distance from the block at which the fly path finder would allow overshooting",
min = 0.05f, max = 0.4f
)
public static float flightAllowedOvershootThreshold = 0.1f;
@Slider(
name = "Max stuck time without motion (in ticks)", category = EXPERIMENTAL, subcategory = "Flight",
description = "The maximum time to wait before unstucking (in ticks)",
min = 30, max = 150
)
public static int flightMaxStuckTimeWithoutMotion = 40;
@Slider(
name = "Max stuck time with motion (in ticks)", category = EXPERIMENTAL, subcategory = "Flight",
description = "The maximum time to wait before unstucking (in ticks)",
min = 30, max = 150
)
public static int flightMaxStuckTimeWithMotion = 100;
@Slider(
name = "Deceleration offset", category = EXPERIMENTAL, subcategory = "Flight",
description = "",
min = 0, max = 15
)
public static int flightDecelerationOffset = 5;
@Slider(
name = "Maximum stuck distance threshold", category = EXPERIMENTAL, subcategory = "Flight",
description = "The maximum distance threshold before unstucking (Vec3)",
min = 0.3f, max = 1.5f
)
public static float flightMaximumStuckDistanceThreshold = 0.75f;
@Switch(
name = "Lock rotation to multipliers of 45 degrees", category = EXPERIMENTAL, subcategory = "Flight",
description = "Locks the rotation to multipliers of 45 degrees"
name = "Use AOTE/V in Pests Destroyer", category = EXPERIMENTAL, subcategory = "Pests Destroyer",
description = "Uses AOTE/V in Pests Destroyer"
)
public static boolean flightLockRotationToMultipliersOf45Degrees = false;
public static boolean useAoteVInPestsDestroyer = true;

@Switch(
name = "Count profit based on Cultivating enchant", category = EXPERIMENTAL, subcategory = "Profit Calculator",
Expand Down Expand Up @@ -2091,7 +2074,7 @@ public FarmHelperConfig() {
registerKeyBind(toggleMacro, () -> MacroHandler.getInstance().toggleMacro());
registerKeyBind(debugKeybind, () -> {

PestsDestroyer.getInstance().resetFireworkInfo();
FailsafeManager.getInstance().possibleDetection(EvacuateFailsafe.getInstance());
});
registerKeyBind(freelookKeybind, () -> Freelook.getInstance().toggle());
registerKeyBind(plotCleaningHelperKeybind, () -> PlotCleaningHelper.getInstance().toggle());
Expand Down
44 changes: 22 additions & 22 deletions src/main/java/com/jelly/farmhelperv2/failsafe/FailsafeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static FailsafeManager getInstance() {
public final ArrayList<Failsafe> emergencyQueue = new ArrayList<>();
@Getter
public final Clock chooseEmergencyDelay = new Clock();
@Getter
private final Clock onTickDelay = new Clock();
@Getter
private final Clock restartMacroAfterFailsafeDelay = new Clock();
Expand Down Expand Up @@ -255,30 +256,29 @@ public void onTickChooseEmergency(TickEvent.ClientTickEvent event) {
if (!MacroHandler.getInstance().isMacroToggled()) return;
if (triggeredFailsafe.isPresent()) return;
if (!chooseEmergencyDelay.isScheduled()) return;
if (!chooseEmergencyDelay.passed()) return;
triggeredFailsafe = Optional.of(getHighestPriorityEmergency());
if (chooseEmergencyDelay.passed()) {
if (triggeredFailsafe.get().getType() == EmergencyType.NONE) {
// Should never happen, but yeh...
LogUtils.sendDebug("[Failsafe] No emergency chosen!");
stopFailsafes();
return;
}
emergencyQueue.clear();
chooseEmergencyDelay.reset();
hadEmergency = true;
LogUtils.sendDebug("[Failsafe] Emergency chosen: " + StringUtils.stripControlCodes(triggeredFailsafe.get().getType().name()));
FeatureManager.getInstance().disableCurrentlyRunning(Scheduler.getInstance());
Scheduler.getInstance().pause();
if (FarmHelperConfig.captureClipAfterFailsafe && !FarmHelperConfig.captureClipKeybind.getKeyBinds().isEmpty()) {
if (FarmHelperConfig.clipCapturingType) {
FailsafeUtils.captureClip();
LogUtils.sendDebug("[Failsafe] Recording clip!");
}
Multithreading.schedule(() -> {
FailsafeUtils.captureClip();
LogUtils.sendDebug("[Failsafe] Clip captured!");
}, FarmHelperConfig.captureClipDelay, TimeUnit.SECONDS);
if (triggeredFailsafe.get().getType() == EmergencyType.NONE) {
// Should never happen, but yeh...
LogUtils.sendDebug("[Failsafe] No emergency chosen!");
stopFailsafes();
return;
}
emergencyQueue.clear();
chooseEmergencyDelay.reset();
hadEmergency = true;
LogUtils.sendDebug("[Failsafe] Emergency chosen: " + StringUtils.stripControlCodes(triggeredFailsafe.get().getType().name()));
FeatureManager.getInstance().disableCurrentlyRunning(Scheduler.getInstance());
Scheduler.getInstance().pause();
if (FarmHelperConfig.captureClipAfterFailsafe && !FarmHelperConfig.captureClipKeybind.getKeyBinds().isEmpty()) {
if (FarmHelperConfig.clipCapturingType) {
FailsafeUtils.captureClip();
LogUtils.sendDebug("[Failsafe] Recording clip!");
}
Multithreading.schedule(() -> {
FailsafeUtils.captureClip();
LogUtils.sendDebug("[Failsafe] Clip captured!");
}, FarmHelperConfig.captureClipDelay, TimeUnit.SECONDS);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import net.minecraftforge.fml.common.gameevent.TickEvent;

import java.awt.*;
import java.util.Collections;
import java.util.Optional;

public class TeleportFailsafe extends Failsafe {
Expand Down Expand Up @@ -99,7 +100,7 @@ public void onReceivedPacketDetection(ReceivePacketEvent event) {
LogUtils.sendDebug("[Failsafe] Teleport packet received while Fly pathfinder is running. Ignoring");
return;
}
Optional<Tuple<BlockPos, AbstractMacro.State>> lastWalkedPosition = lastWalkedPositions.stream().filter(pos -> pos.getFirst().equals(packetPlayerBlockPos)).findFirst();
Optional<Tuple<BlockPos, AbstractMacro.State>> lastWalkedPosition = lastWalkedPositions.stream().filter(pos -> pos.getFirst().equals(packetPlayerBlockPos)).min(Collections.reverseOrder());
if (lastWalkedPosition.isPresent()) {
if (packetPlayerPos.distanceTo(currentPlayerPos) < 1) {
LogUtils.sendDebug("[Failsafe] AntiStuck should trigger there. Ignoring");
Expand Down Expand Up @@ -170,14 +171,6 @@ public void onTickDetection(TickEvent.ClientTickEvent event) {
}

BlockPos playerPos = mc.thePlayer.getPosition();
if (lastWalkedPositions.isEmpty()) {
lastWalkedPositions.add(new Tuple<>(playerPos, MacroHandler.getInstance().getCurrentMacro().map(AbstractMacro::getCurrentState).orElse(null)));
return;
}
BlockPos last = ((Tuple<BlockPos, AbstractMacro.State>) lastWalkedPositions.toArray()[lastWalkedPositions.size() - 1]).getFirst();
if (last.distanceSq(playerPos) < 1) {
return;
}
lastWalkedPositions.add(new Tuple<>(playerPos, MacroHandler.getInstance().getCurrentMacro().map(AbstractMacro::getCurrentState).orElse(null)));
}

Expand Down
42 changes: 19 additions & 23 deletions src/main/java/com/jelly/farmhelperv2/feature/impl/AutoBazaar.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static AutoBazaar getInstance() {
private BuyState buyState = BuyState.STARTING;
private String itemToBuy = null;
private int buyAmount = 0;
private int maxSpendLimit = 0;
private float maxSpendLimit = 0;
private int buyNowButtonSlot = -1;

// Sell
Expand Down Expand Up @@ -120,7 +120,7 @@ public void buy(String itemName, int amount) {
this.buy(itemName, amount, 0);
}

public void buy(String itemName, int amount, int maxSpendLimit) {
public void buy(String itemName, int amount, float maxSpendLimit) {
if (this.enabled) return;

this.enabled = true;
Expand Down Expand Up @@ -357,29 +357,25 @@ private void handleBuyFromBz() {

boolean foundPrice = false;

if (this.maxSpendLimit != 0) {
String lore = String.join(" ", InventoryUtils.getItemLore(slot.getStack())).replace(",", "");
Matcher matcher = this.totalCostPattern.matcher(lore);
System.out.println(lore);

if (matcher.find()) {
float amount = Float.parseFloat(matcher.group(1));
System.out.println("Amount: " + amount);
System.out.println("Max spend limit: " + this.maxSpendLimit);
foundPrice = true;
if (amount > this.maxSpendLimit) {
log("Attempting to spend more than allowed. Price: " + amount + ", limit: " + this.maxSpendLimit);
log("Disabling.");
this.wasManipulated = true;
this.disable("Spending more than allowed.");
return;
}
}
// For high pong gamers - Might get stuck in an inf loop here if internet is bad
if (lore.contains("Loading...")) return;
} else {
String lore = String.join(" ", InventoryUtils.getItemLore(slot.getStack())).replace(",", "");
Matcher matcher = this.totalCostPattern.matcher(lore);
System.out.println(lore);

if (matcher.find()) {
float amount = Float.parseFloat(matcher.group(1));
System.out.println("Amount: " + amount);
System.out.println("Max spend limit: " + this.maxSpendLimit);
foundPrice = true;
if (this.maxSpendLimit > 0 && amount > this.maxSpendLimit) {
log("Attempting to spend more than allowed. Price: " + amount + ", limit: " + this.maxSpendLimit);
log("Disabling.");
this.wasManipulated = true;
this.disable("Spending more than allowed.");
return;
}
}
// For high pong gamers - Might get stuck in an inf loop here if internet is bad
if (lore.contains("Loading...")) return;

if (!foundPrice) {
this.disable("Could not find price.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cc.polyfrost.oneconfig.utils.Multithreading;
import com.jelly.farmhelperv2.config.FarmHelperConfig;
import com.jelly.farmhelperv2.failsafe.FailsafeManager;
import com.jelly.farmhelperv2.feature.FeatureManager;
import com.jelly.farmhelperv2.feature.IFeature;
import com.jelly.farmhelperv2.handler.GameStateHandler;
Expand Down Expand Up @@ -140,6 +141,7 @@ public void onTickShouldEnable(TickEvent.ClientTickEvent event) {
if (!isToggled()) return;
if (isRunning()) return;
if (!MacroHandler.getInstance().isMacroToggled()) return;
if (FailsafeManager.getInstance().triggeredFailsafe.isPresent()) return;
if (FeatureManager.getInstance().isAnyOtherFeatureEnabled(this)) return;
if (!GameStateHandler.getInstance().inGarden()) return;
if (GameStateHandler.getInstance().getServerClosingSeconds().isPresent()) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cc.polyfrost.oneconfig.utils.Multithreading;
import com.jelly.farmhelperv2.config.FarmHelperConfig;
import com.jelly.farmhelperv2.failsafe.FailsafeManager;
import com.jelly.farmhelperv2.feature.FeatureManager;
import com.jelly.farmhelperv2.feature.IFeature;
import com.jelly.farmhelperv2.handler.GameStateHandler;
Expand Down Expand Up @@ -183,6 +184,7 @@ public void onTickShouldEnable(TickEvent.ClientTickEvent event) {
if (mc.thePlayer == null || mc.theWorld == null) return;
if (!isToggled()) return;
if (isRunning()) return;
if (FailsafeManager.getInstance().triggeredFailsafe.isPresent()) return;
if (!MacroHandler.getInstance().isMacroToggled()) return;
if (FeatureManager.getInstance().isAnyOtherFeatureEnabled(this)) return;
if (!GameStateHandler.getInstance().inGarden()) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cc.polyfrost.oneconfig.utils.Multithreading;
import com.jelly.farmhelperv2.config.FarmHelperConfig;
import com.jelly.farmhelperv2.event.DrawScreenAfterEvent;
import com.jelly.farmhelperv2.failsafe.FailsafeManager;
import com.jelly.farmhelperv2.feature.FeatureManager;
import com.jelly.farmhelperv2.feature.IFeature;
import com.jelly.farmhelperv2.handler.GameStateHandler;
Expand Down Expand Up @@ -145,6 +146,7 @@ public void onTickShouldEnable(TickEvent.ClientTickEvent event) {
if (!MacroHandler.getInstance().isMacroToggled()) return;
if (GameStateHandler.getInstance().getServerClosingSeconds().isPresent()) return;
if (FeatureManager.getInstance().isAnyOtherFeatureEnabled(this)) return;
if (FailsafeManager.getInstance().triggeredFailsafe.isPresent()) return;
if (!GameStateHandler.getInstance().inGarden()) return;
if (RotationHandler.getInstance().isRotating()) return;
if (FarmHelperConfig.pauseAutoPestRepellentDuringJacobsContest && GameStateHandler.getInstance().inJacobContest())
Expand Down Expand Up @@ -181,6 +183,10 @@ public void onTickExecution(TickEvent.ClientTickEvent event) {
if (!enabled) return;
if (!isToggled()) return;
if (!MacroHandler.getInstance().isMacroToggled()) return;
if (GameStateHandler.getInstance().getServerClosingSeconds().isPresent()) {
stop();
return;
}
if (FeatureManager.getInstance().isAnyOtherFeatureEnabled(this)) return;
if (!GameStateHandler.getInstance().inGarden()) return;

Expand Down Expand Up @@ -325,11 +331,12 @@ public void onTickExecution(TickEvent.ClientTickEvent event) {
case OPEN_SKYMART:
case CLICK_REPELLENT:
case CONFIRM_BUY:
case END:
break;
case WAIT_FOR_REPELLENT:
if (!delay.passed()) break;
LogUtils.sendError("[Auto Repellent] Repellent hasn't been used. Trying to use again.");
state = State.USE_REPELLENT;
case END:
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cc.polyfrost.oneconfig.utils.Multithreading;
import com.jelly.farmhelperv2.config.FarmHelperConfig;
import com.jelly.farmhelperv2.event.InventoryInputEvent;
import com.jelly.farmhelperv2.failsafe.FailsafeManager;
import com.jelly.farmhelperv2.feature.FeatureManager;
import com.jelly.farmhelperv2.feature.IFeature;
import com.jelly.farmhelperv2.handler.GameStateHandler;
Expand Down Expand Up @@ -188,6 +189,7 @@ public void onTickShouldEnable(TickEvent.ClientTickEvent event) {
if (isRunning()) return;
if (!MacroHandler.getInstance().isMacroToggled()) return;
if (!GameStateHandler.getInstance().inGarden()) return;
if (FailsafeManager.getInstance().triggeredFailsafe.isPresent()) return;
if (GameStateHandler.getInstance().getServerClosingSeconds().isPresent()) return;
if (GameStateHandler.getInstance().getCookieBuffState() != GameStateHandler.BuffState.ACTIVE) return;
if (FeatureManager.getInstance().isAnyOtherFeatureEnabled(this)) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.jelly.farmhelperv2.config.FarmHelperConfig.SPRAYONATOR_ITEM;
import com.jelly.farmhelperv2.event.DrawScreenAfterEvent;
import com.jelly.farmhelperv2.event.ReceivePacketEvent;
import com.jelly.farmhelperv2.failsafe.FailsafeManager;
import com.jelly.farmhelperv2.feature.FeatureManager;
import com.jelly.farmhelperv2.feature.IFeature;
import com.jelly.farmhelperv2.handler.GameStateHandler;
Expand Down Expand Up @@ -218,6 +219,7 @@ public void onTickShouldEnable(TickEvent.ClientTickEvent event) {
if (!Scheduler.getInstance().isFarming()) return;
if (!MacroHandler.getInstance().isMacroToggled()) return;
if (GameStateHandler.getInstance().getServerClosingSeconds().isPresent()) return;
if (FailsafeManager.getInstance().triggeredFailsafe.isPresent()) return;
if (!GameStateHandler.getInstance().inGarden()) return;
if (sprayState == AUTO_SPRAYONATOR_STATE.NO_ITEM) return;
if (sprayState != AUTO_SPRAYONATOR_STATE.NONE) return;
Expand Down
Loading

0 comments on commit 5f188d9

Please sign in to comment.