Skip to content

Commit

Permalink
= AutoGodPot - bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
onixiya1337 committed Feb 29, 2024
1 parent aa5f973 commit 39f57b9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 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.4.5-pre17
version=2.4.5-pre18
shouldRelease=true
33 changes: 24 additions & 9 deletions src/main/java/com/jelly/farmhelperv2/feature/impl/AutoGodPot.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import cc.polyfrost.oneconfig.utils.Multithreading;
import com.jelly.farmhelperv2.config.FarmHelperConfig;
import com.jelly.farmhelperv2.failsafe.Failsafe;
import com.jelly.farmhelperv2.failsafe.FailsafeManager;
import com.jelly.farmhelperv2.feature.FeatureManager;
import com.jelly.farmhelperv2.feature.IFeature;
import com.jelly.farmhelperv2.handler.GameStateHandler;
import com.jelly.farmhelperv2.handler.MacroHandler;
import com.jelly.farmhelperv2.handler.RotationHandler;
import com.jelly.farmhelperv2.util.InventoryUtils;
import com.jelly.farmhelperv2.util.KeyBindUtils;
import com.jelly.farmhelperv2.util.LogUtils;
import com.jelly.farmhelperv2.util.PlayerUtils;
import com.jelly.farmhelperv2.util.*;
import com.jelly.farmhelperv2.util.helper.Clock;
import com.jelly.farmhelperv2.util.helper.Rotation;
import com.jelly.farmhelperv2.util.helper.RotationConfiguration;
Expand All @@ -28,6 +27,7 @@
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;

import java.awt.*;
import java.util.ArrayList;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -67,6 +67,7 @@ public class AutoGodPot implements IFeature {
@Getter
private BitsShopState bitsShopState = BitsShopState.NONE;
private Slot godPotItem;
private int teleportTries = 0;

public static AutoGodPot getInstance() {
if (instance == null) {
Expand Down Expand Up @@ -144,13 +145,26 @@ public void stop() {
resetBitsShopState();
godPotMode = GodPotMode.NONE;
KeyBindUtils.stopMovement();
if (shouldTpToGarden)
MacroHandler.getInstance().triggerWarpGarden(true, true);
LogUtils.sendWarning("[Auto God Pot] Disabled!");
shouldTpToGarden = true;
teleportToGarden();
}

private void teleportToGarden() {
if (teleportTries >= 3) {
LogUtils.sendError("[Auto God Pot] Could not teleport to garden after 3 tries! Disabling Auto God Pot!");
LogUtils.webhookLog("[Auto God Pot]\\nCould not teleport to garden after 3 tries! Disabling Auto God Pot!");
teleportTries = 0;
return;
}
Multithreading.schedule(() -> {
LogUtils.sendWarning("[Auto God Pot] Disabled!");
if (MacroHandler.getInstance().isMacroToggled()) {
if (!GameStateHandler.getInstance().inGarden() && shouldTpToGarden) {
MacroHandler.getInstance().triggerWarpGarden(true, true);
teleportToGarden();
teleportTries++;
} else if (GameStateHandler.getInstance().inGarden() && MacroHandler.getInstance().isMacroToggled()) {
MacroHandler.getInstance().resumeMacro();
teleportTries = 0;
}
}, 4_000, TimeUnit.MILLISECONDS);
}
Expand All @@ -166,7 +180,8 @@ public boolean isToggled() {

@Override
public boolean shouldCheckForFailsafes() {
return goingToAHState != GoingToAHState.NONE && bitsShopState != BitsShopState.NONE;
return goingToAHState != GoingToAHState.NONE && bitsShopState != BitsShopState.NONE
&& goingToAHState != GoingToAHState.TELEPORT_TO_HUB && bitsShopState != BitsShopState.TELEPORT_TO_HUB;
}

@SubscribeEvent
Expand Down

0 comments on commit 39f57b9

Please sign in to comment.