Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If Baritone is paused, then InfinityMiner doesn't put the mending pickaxe in the player's hand #5220

Closed
wants to merge 7 commits into from
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
* Copyright (c) Meteor Development.
* Copyright (c) Meteor Development (https://github.com/MeteorDevelopment).
*/

package meteordevelopment.meteorclient.systems.modules.world;
Expand Down Expand Up @@ -37,6 +37,8 @@
public class InfinityMiner extends Module {
private final SettingGroup sgGeneral = settings.getDefaultGroup();
private final SettingGroup sgWhenFull = settings.createGroup("When Full");
private int tickCounter = 0;
private boolean isBaritonePaused = false;

// General

Expand Down Expand Up @@ -125,6 +127,27 @@ public void onDeactivate() {

@EventHandler
private void onTick(TickEvent.Post event) {
tickCounter++;

// Every 20 ticks, check if Baritone is paused
if (tickCounter >= 20) {
tickCounter = 0;

// Check if Baritone is paused
if (isBaritoneNotPaused()) {
isBaritonePaused = false; // Continue processing if Baritone is unpaused
} else {
isBaritonePaused = true; // Set flag to true if Baritone is paused
return; // Skip the rest of the method if Baritone is paused
}
}

// If Baritone is paused, return early to prevent further actions
if (isBaritonePaused) {
return;
}

// Rest of the logic continues if Baritone is not paused
if (isFull()) {
if (walkHome.get()) {
if (isBaritoneNotWalking()) {
Expand Down Expand Up @@ -158,19 +181,22 @@ private void onTick(TickEvent.Post event) {
if (!needsRepair()) {
warning("Finished repairing, going back to mining.");
repairing = false;
baritoneSettings.mineScanDroppedItems.value = true;
mineTargetBlocks();
return;
}

if (isBaritoneNotMining()) mineRepairBlocks();
}

else {
if (needsRepair()) {
warning("Pickaxe needs repair, beginning repair process");
repairing = true;
baritoneSettings.mineScanDroppedItems.value = false;
mineRepairBlocks();
return;
}
}

if (isBaritoneNotMining()) mineTargetBlocks();
}
Expand All @@ -182,6 +208,10 @@ private boolean needsRepair() {
return !(toolPercentage > startMining.get() || (toolPercentage > startRepairing.get() && !repairing));
}

private boolean isBaritoneNotPaused() {
return baritone.getPathingControlManager().mostRecentInControl().isEmpty();
}

private boolean findPickaxe() {
Predicate<ItemStack> pickaxePredicate = (stack -> stack.getItem() instanceof PickaxeItem
&& Utils.hasEnchantment(stack, Enchantments.MENDING)
Expand Down Expand Up @@ -243,4 +273,4 @@ private boolean isFull() {

return true;
}
}
}