Skip to content

Commit

Permalink
+ Optimizations
Browse files Browse the repository at this point in the history
Auto Bazaar:
 = Fixed issue of getting stuck randomly

Auto God Pot:
 + Added tp do Elizabeth directly (for bits shop)
 = Won't stuck while opening Elizabeth shop
 = Possible fix for buying multiple god pots if user has high ping

Auto Repellent:
 + Added retry to use repellent if it wasn't used for the past 3 seconds of trying

Failsafes:
 = Jacob fixed (i hope so, lmk)
 = Should always detect limbo (not sure why it didn't detect sometimes)
 = Lower avg bps being counted in other features fixed

Pests Destroyer:
 + Faster Vacuum scanner - Credits to Skyhanni lol

PDOTT:
 + Won't trigger during scheduler break (oops)

Visitors Macro:
 + Improved by a lot, need further testing

- Removed some console logs to improve a little performance
  • Loading branch information
May2Beez committed Apr 23, 2024
1 parent 7dd893b commit 1f89eb9
Show file tree
Hide file tree
Showing 41 changed files with 423 additions and 423 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.1
version=2.6.2
shouldRelease=true
2 changes: 0 additions & 2 deletions src/main/java/com/jelly/farmhelperv2/FarmHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.jelly.farmhelperv2.util.*;
import com.jelly.farmhelperv2.util.helper.AudioManager;
import com.jelly.farmhelperv2.util.helper.BaritoneEventListener;
import com.jelly.farmhelperv2.util.helper.FlyPathfinder;
import com.jelly.farmhelperv2.util.helper.TickTask;
import net.minecraft.client.Minecraft;
import net.minecraftforge.client.ClientCommandHandler;
Expand Down Expand Up @@ -114,7 +113,6 @@ private void initializeListeners() {
MinecraftForge.EVENT_BUS.register(DiscordBotHandler.getInstance());
MinecraftForge.EVENT_BUS.register(AudioManager.getInstance());
MinecraftForge.EVENT_BUS.register(RotationHandler.getInstance());
MinecraftForge.EVENT_BUS.register(FlyPathfinder.getInstance());
MinecraftForge.EVENT_BUS.register(FlyPathFinderExecutor.getInstance());
MinecraftForge.EVENT_BUS.register(new TablistUtils());
MinecraftForge.EVENT_BUS.register(new ScoreboardUtils());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2090,7 +2090,7 @@ public FarmHelperConfig() {
registerKeyBind(openGuiKeybind, this::openGui);
registerKeyBind(toggleMacro, () -> MacroHandler.getInstance().toggleMacro());
registerKeyBind(debugKeybind, () -> {
// mc.thePlayer.sendChatMessage("§");
AutoGodPot.getInstance().start();
});
registerKeyBind(freelookKeybind, () -> Freelook.getInstance().toggle());
registerKeyBind(plotCleaningHelperKeybind, () -> PlotCleaningHelper.getInstance().toggle());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void onChatDetection(ClientChatReceivedEvent event) {
if (event.message == null) return;
if (!MacroHandler.getInstance().isMacroToggled()) return;
if (triggeredFailsafe.isPresent()) return;
if (FeatureManager.getInstance().shouldIgnoreFalseCheck()) return;
// if (FeatureManager.getInstance().shouldIgnoreFalseCheck()) return;

failsafes.forEach(failsafe -> failsafe.onChatDetection(event));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.jelly.farmhelperv2.failsafe.impl;

import baritone.api.pathing.goals.GoalBlock;
import com.jelly.farmhelperv2.config.FarmHelperConfig;
import com.jelly.farmhelperv2.config.page.CustomFailsafeMessagesPage;
import com.jelly.farmhelperv2.config.page.FailsafeNotificationsPage;
Expand All @@ -11,8 +10,8 @@
import com.jelly.farmhelperv2.handler.BaritoneHandler;
import com.jelly.farmhelperv2.handler.GameStateHandler;
import com.jelly.farmhelperv2.handler.MacroHandler;
import com.jelly.farmhelperv2.pathfinder.FlyPathFinderExecutor;
import com.jelly.farmhelperv2.util.*;
import com.jelly.farmhelperv2.util.helper.FlyPathfinder;
import com.jelly.farmhelperv2.util.helper.Rotation;
import com.jelly.farmhelperv2.util.helper.RotationConfiguration;
import net.minecraft.init.Blocks;
Expand Down Expand Up @@ -193,7 +192,7 @@ else if (BlockUtils.getRelativeBlock(1, 1, 0).equals(Blocks.dirt))
MovRecPlayer.getInstance().playRandomRecording(tempRecordingName);
maxReactions--;
} else {
FlyPathfinder.getInstance().getPathTo(new GoalBlock(positionBeforeReacting.getX(), positionBeforeReacting.getY() + 3, positionBeforeReacting.getZ()));
FlyPathFinderExecutor.getInstance().findPath(new Vec3(positionBeforeReacting.getX() + 0.5, positionBeforeReacting.getY() + 3, positionBeforeReacting.getZ() + 0.5), true, true);
dirtCheckState = DirtCheckState.GO_BACK_END;
}
FailsafeManager.getInstance().scheduleRandomDelay(500, 1000);
Expand All @@ -203,7 +202,7 @@ else if (BlockUtils.getRelativeBlock(1, 1, 0).equals(Blocks.dirt))
break;
if (FailsafeManager.getInstance().swapItemDuringRecording)
FailsafeManager.getInstance().swapItemDuringRecording = false;
if (FlyPathfinder.getInstance().isRunning())
if (FlyPathFinderExecutor.getInstance().isRunning())
break;
if (mc.thePlayer.getPosition().distanceSq(positionBeforeReacting) < 1) {
dirtCheckState = DirtCheckState.ROTATE_TO_POS_BEFORE;
Expand All @@ -213,7 +212,7 @@ else if (BlockUtils.getRelativeBlock(1, 1, 0).equals(Blocks.dirt))
dirtCheckState = DirtCheckState.GO_BACK_END;
break;
case GO_BACK_END:
if (FlyPathfinder.getInstance().isRunning())
if (FlyPathFinderExecutor.getInstance().isRunning())
break;
if (BaritoneHandler.isWalkingToGoalBlock()) {
LogUtils.sendDebug("Distance difference: " + mc.thePlayer.getPosition().distanceSq(positionBeforeReacting));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

public class JacobFailsafe extends Failsafe {
private static JacobFailsafe instance;

public static JacobFailsafe getInstance() {
if (instance == null) {
instance = new JacobFailsafe();
Expand Down Expand Up @@ -105,11 +106,9 @@ public void duringFailsafeTrigger() {
if (!MacroHandler.getInstance().isCurrentMacroPaused()) {
LogUtils.sendFailsafeMessage("[Failsafe] Paused the macro because of extended Jacob's Content!", false);
MacroHandler.getInstance().pauseMacro();
} else {
if (!GameStateHandler.getInstance().inJacobContest()) {
LogUtils.sendFailsafeMessage("[Failsafe] Resuming the macro because Jacob's Contest is over!", false);
endOfFailsafeTrigger();
}
} else if (!GameStateHandler.getInstance().inJacobContest()) {
LogUtils.sendFailsafeMessage("[Failsafe] Resuming the macro because Jacob's Contest is over!", false);
endOfFailsafeTrigger();
}
} else {
// leave
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.jelly.farmhelperv2.config.page.FailsafeNotificationsPage;
import com.jelly.farmhelperv2.failsafe.Failsafe;
import com.jelly.farmhelperv2.failsafe.FailsafeManager;
import com.jelly.farmhelperv2.feature.FeatureManager;
import com.jelly.farmhelperv2.feature.impl.ProfitCalculator;
import com.jelly.farmhelperv2.handler.GameStateHandler;
import com.jelly.farmhelperv2.handler.MacroHandler;
Expand Down Expand Up @@ -56,7 +57,7 @@ public boolean shouldAltTab() {

@Override
public void onTickDetection(TickEvent.ClientTickEvent event) {
if (MacroHandler.getInstance().isCurrentMacroPaused()) {
if (MacroHandler.getInstance().isCurrentMacroPaused() || FeatureManager.getInstance().shouldPauseMacroExecution()) {
bpsQueue.clear();
lastTimeCheckedBPS = System.currentTimeMillis();
return;
Expand Down
26 changes: 16 additions & 10 deletions src/main/java/com/jelly/farmhelperv2/feature/FeatureManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import com.jelly.farmhelperv2.feature.impl.*;
import com.jelly.farmhelperv2.util.LogUtils;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;

public class FeatureManager {
private static FeatureManager instance;
Expand All @@ -18,6 +18,10 @@ public static FeatureManager getInstance() {
return instance;
}

@Getter
@Setter
private Set<IFeature> pauseExecutionFeatures = new HashSet<>();

public List<IFeature> fillFeatures() {
List<IFeature> featuresList = Arrays.asList(
AutoBazaar.getInstance(),
Expand Down Expand Up @@ -50,12 +54,7 @@ public List<IFeature> fillFeatures() {
}

public boolean shouldPauseMacroExecution() {
return features.stream().anyMatch(feature -> {
if (feature.isToggled() && feature.isRunning()) {
return feature.shouldPauseMacroExecution();
}
return false;
});
return !pauseExecutionFeatures.isEmpty();
}

public void disableAll() {
Expand All @@ -65,12 +64,14 @@ public void disableAll() {
LogUtils.sendDebug("Disabled feature: " + feature.getName());
}
});
pauseExecutionFeatures.clear();
}

public void disableAllExcept(IFeature... sender) {
features.forEach(feature -> {
if (feature.isToggled() && feature.isRunning() && !Arrays.asList(sender).contains(feature)) {
feature.stop();
pauseExecutionFeatures.remove(feature);
LogUtils.sendDebug("Disabled feature: " + feature.getName());
}
});
Expand All @@ -80,8 +81,13 @@ public void resetAllStates() {
features.forEach(IFeature::resetStatesAfterMacroDisabled);
}

public boolean isAnyOtherFeatureEnabled(IFeature sender) {
return pauseExecutionFeatures.stream().anyMatch(f -> f != sender);
}

public boolean isAnyOtherFeatureEnabled(IFeature... sender) {
return features.stream().anyMatch(feature -> feature.shouldPauseMacroExecution() && feature.isRunning() && !Arrays.asList(sender).contains(feature));
return pauseExecutionFeatures.stream().anyMatch(f -> !Arrays.asList(sender).contains(f));
// return features.stream().anyMatch(feature -> feature.shouldPauseMacroExecution() && feature.isRunning() && !Arrays.asList(sender).contains(feature));
}

public boolean shouldIgnoreFalseCheck() {
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/com/jelly/farmhelperv2/feature/IFeature.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ public interface IFeature {

boolean shouldStartAtMacroStart();

void start();

void stop();
default void start() {
if (!shouldPauseMacroExecution()) return;
FeatureManager.getInstance().getPauseExecutionFeatures().add(this);
}

default void stop() {
if (!shouldPauseMacroExecution()) return;
FeatureManager.getInstance().getPauseExecutionFeatures().remove(this);
}

void resetStatesAfterMacroDisabled();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void start() {
enabled = true;
unstuckState = UnstuckState.NONE;
KeyBindUtils.stopMovement();
IFeature.super.start();
}

@Override
Expand All @@ -104,6 +105,7 @@ public void stop() {
intersectingBlockPos = null;
directionBlockPos = null;
unstuckTries++;
IFeature.super.stop();
}

@Override
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/com/jelly/farmhelperv2/feature/impl/AutoBazaar.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ public boolean shouldStartAtMacroStart() {
return false;
}

// Cant use this prob idk
@Override
public void start() {
IFeature.super.start();
}

@Override
Expand All @@ -96,6 +96,7 @@ public void stop() {
this.maxSpendLimit = 0;

log("Disabling");
IFeature.super.stop();
}

@Override
Expand Down Expand Up @@ -135,6 +136,7 @@ public void buy(String itemName, int amount, int maxSpendLimit) {
this.maxSpendLimit = maxSpendLimit;

log("Enabling");
start();
}

public void sell(Integer... sellTypes) {
Expand Down Expand Up @@ -276,7 +278,7 @@ private void handleBuyFromBz() {
Slot customAmount = InventoryUtils.getSlotOfItemInContainer("Custom Amount");
if (customAmount != null && customAmount.getHasStack()) {
this.buyState = BuyState.OPEN_SIGN;
this.buyNowButtonSlot = 13;
this.buyNowButtonSlot = -1;
LogUtils.sendDebug("[Auto Bazaar] Buying custom amount");
return;
}
Expand Down Expand Up @@ -337,6 +339,16 @@ private void handleBuyFromBz() {
case CLICK_BUY:
if (!this.hasTimerEnded()) return;

if (buyNowButtonSlot == -1) {
Slot customAmount = InventoryUtils.getSlotOfItemInContainer("Custom Amount");
if (customAmount != null && customAmount.getHasStack()) {
this.buyNowButtonSlot = customAmount.slotNumber;
} else {
System.out.println("Slot is null 2");
return;
}
}

Slot slot = InventoryUtils.getSlotOfIdInContainer(buyNowButtonSlot);
if (slot == null || !slot.getHasStack()) {
System.out.println("Slot is null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void start() {
timeoutClock.schedule(7_500);
if (MacroHandler.getInstance().isMacroToggled())
MacroHandler.getInstance().pauseMacro();
IFeature.super.start();
}

@Override
Expand All @@ -99,6 +100,7 @@ public void stop() {
KeyBindUtils.stopMovement();
if (MacroHandler.getInstance().isMacroToggled())
MacroHandler.getInstance().resumeMacro();
IFeature.super.stop();
}

@Override
Expand Down Expand Up @@ -263,6 +265,7 @@ public void onTickUpdate(TickEvent.ClientTickEvent event) {
break;
}

mc.thePlayer.swingItem();
mc.playerController.interactWithEntitySendPacket(mc.thePlayer, bazaarNpc.get());
setBazaarState(BazaarState.CLICK_ODDITIES);
autoCookieDelay.schedule(getRandomDelay());
Expand Down
Loading

0 comments on commit 1f89eb9

Please sign in to comment.