Skip to content

Commit

Permalink
AutoSell:
Browse files Browse the repository at this point in the history
 = Tweak

Profit Calc:
 = Fixed rare crash
  • Loading branch information
May2Beez committed Apr 20, 2024
1 parent 956112a commit 0ba6ad3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 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.25
version=2.5.26
shouldRelease=true
26 changes: 9 additions & 17 deletions src/main/java/com/jelly/farmhelperv2/feature/impl/AutoSell.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ public void onTickEnabled(TickEvent.ClientTickEvent event) {
}
if (FeatureManager.getInstance().isAnyOtherFeatureEnabled(this, VisitorsMacro.getInstance())) return;


if (timeoutClock.isScheduled() && timeoutClock.passed()) {
LogUtils.sendWarning("[Auto Sell] Timeout reached, disabling Auto Sell");
stop();
return;
}

if (delayClock.isScheduled() && !delayClock.passed()) return;

switch (sacksState) {
Expand Down Expand Up @@ -359,17 +366,9 @@ public void onTickEnabled(TickEvent.ClientTickEvent event) {
break;
case SELL_INV:
if (mc.currentScreen == null) {
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
setBazaarState(BazaarState.OPEN_MENU);
break;
}
if (InventoryUtils.getInventoryName() != null && !InventoryUtils.getInventoryName().contains("Bazaar")) {
LogUtils.sendDebug("[Auto Sell] Wrong menu detected!");
PlayerUtils.closeScreen();
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
setBazaarState(BazaarState.OPEN_MENU);
break;
} else if (InventoryUtils.getInventoryName() == null) {
if (InventoryUtils.getInventoryName() == null || !InventoryUtils.getInventoryName().contains("Bazaar")) {
break;
}
LogUtils.sendDebug("[Auto Sell] Detected BZ menu");
Expand Down Expand Up @@ -400,9 +399,7 @@ public void onTickEnabled(TickEvent.ClientTickEvent event) {
break;
case SELL_INV_CONFIRM:
if (mc.currentScreen == null) return;
if (InventoryUtils.getInventoryName() != null && !InventoryUtils.getInventoryName().contains("Are you sure?")) {
break;
} else if (InventoryUtils.getInventoryName() == null) {
if (InventoryUtils.getInventoryName() == null || !InventoryUtils.getInventoryName().contains("Are you sure?")) {
break;
}
LogUtils.sendDebug("[Auto Sell] Detected sell confirmation menu");
Expand Down Expand Up @@ -530,11 +527,6 @@ public void onTickEnabled(TickEvent.ClientTickEvent event) {
}
break;
}

if (timeoutClock.isScheduled() && timeoutClock.passed()) {
LogUtils.sendWarning("[Auto Sell] Timeout reached, disabling Auto Sell");
stop();
}
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ public void resetProfits() {
private final HashMap<String, Long> previousCultivating = new HashMap<>();

@SubscribeEvent
public void onTickUpdateProfit(TickEvent.ClientTickEvent event) {
public void onTickUpdateProfit(TickEvent.PlayerTickEvent event) {
if (event.phase != TickEvent.Phase.START) return;
if (mc.thePlayer == null) return;
if (!MacroHandler.getInstance().isMacroToggled()) return;
if (MacroHandler.getInstance().isCurrentMacroPaused()) return;

Expand Down

0 comments on commit 0ba6ad3

Please sign in to comment.