Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@
import meteordevelopment.meteorclient.events.meteor.KeyEvent;
import meteordevelopment.meteorclient.events.meteor.MouseButtonEvent;
import meteordevelopment.meteorclient.events.render.Render3DEvent;
import meteordevelopment.meteorclient.events.world.TickEvent;
import meteordevelopment.meteorclient.renderer.ShapeMode;
import meteordevelopment.meteorclient.settings.*;
import meteordevelopment.meteorclient.systems.modules.Categories;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.utils.misc.Keybind;
import meteordevelopment.meteorclient.utils.misc.input.KeyAction;
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.item.ItemStack;
import net.minecraft.util.hit.BlockHitResult;
import org.lwjgl.glfw.GLFW;

Expand Down Expand Up @@ -50,6 +53,13 @@ public class Excavator extends Module {
.build()
);

private final Setting<Boolean> disableLowDura = sgGeneral.add(new BoolSetting.Builder()
.name("disable-low-dura")
.description("Disable the module when your main hand tool has < 100 durability to prevent it from breaking.")
.defaultValue(false)
.build()
);

// Rendering
private final Setting<ShapeMode> shapeMode = sgRendering.add(new EnumSetting.Builder<ShapeMode>()
.name("shape-mode")
Expand All @@ -75,6 +85,7 @@ public class Excavator extends Module {
private enum Status {
SEL_START,
SEL_END,
READY_TO_WORK, // New state
WORKING
}

Expand All @@ -92,6 +103,30 @@ public void onDeactivate() {
status = Status.SEL_START;
}

@EventHandler
private void onTick(TickEvent.Post event) {
if (disableLowDura.get()) {
if (isToolLowDurability()) {
info("Tool durability is below 100, stopping Excavator to prevent breaking.");
toggle();
return;
}
}

if (status == Status.READY_TO_WORK && !baritone.getBuilderProcess().isActive()) {
baritone.getBuilderProcess().clearArea(start, end);
status = Status.WORKING;
}
}

private boolean isToolLowDurability() {
ItemStack mainHandStack = mc.player.getMainHandStack();
if (mainHandStack.isEmpty() || !mainHandStack.isDamageable()) {
return false;
}
return mainHandStack.getMaxDamage() - mainHandStack.getDamage() < 100;
}

@EventHandler
private void onMouseButton(MouseButtonEvent event) {
if (event.action != KeyAction.Press || !selectionBind.get().isPressed() || mc.currentScreen != null) {
Expand Down Expand Up @@ -119,12 +154,11 @@ private void selectCorners() {
}
} else if (status == Status.SEL_END) {
end = BetterBlockPos.from(result.getBlockPos());
status = Status.WORKING;
status = Status.READY_TO_WORK;
if (logSelection.get()) {
info("End corner set: (%d, %d, %d)".formatted(end.getX(), end.getY(), end.getZ()));
}
baritone.getSelectionManager().addSelection(start, end);
baritone.getBuilderProcess().clearArea(start, end);
}
}

Expand All @@ -133,11 +167,15 @@ private void onRender3D(Render3DEvent event) {
if (status == Status.SEL_START || status == Status.SEL_END) {
if (!(mc.crosshairTarget instanceof BlockHitResult result)) return;
event.renderer.box(result.getBlockPos(), sideColor.get(), lineColor.get(), shapeMode.get(), 0);
} else if (status == Status.WORKING && !baritone.getBuilderProcess().isActive()) {
if (keepActive.get()) {
} else if (status == Status.WORKING) {
if (!baritone.getBuilderProcess().isActive()) {
baritone.getSelectionManager().removeSelection(baritone.getSelectionManager().getLastSelection());
status = Status.SEL_START;
} else toggle();
if (keepActive.get()) {
status = Status.SEL_START;
} else {
toggle();
}
}
}
}
}
}