SuperNova

i want a which automatically mines desired ore for me by tracking and automatically going throurough the safest route and trying to mine with whatber is selcted

Kodari AI
KodariNov 7 at 8:44 pm 9
AutoOreMiner
A Fabric mod that automatically locates and mines a desired ore for the player. It scans the surrounding area for target ore blocks, calculates the safest path avoiding lava, caves, and hostile mobs, then autonomously navigates and mines using the currently selected tool. Includes configurable ore selection, mining radius, safety preferences, and automatic tool switching when durability runs low. The mod works in real-time, updating its route as the environment changes, and can pause when inventory is full or player health is low.

I’ll build a client-side ore miner with a start/stop command, loaded-area scanning, and conservative route checks. It will use the item currently selected in your hotbar.

Created the client-side auto-miner.

  • Start: /automine start minecraft:diamond_ore

  • Stop: /automine stop

It uses the currently selected item and searches nearby loaded areas for exposed matching blocks. Routes are limited to flat, walkable ground and avoid nearby fluids and common hazards; they aren’t guaranteed safe from mobs or every danger. It won’t dig tunnels or change elevation.

SuperNova

edit this mod to be compatible with fabric loader 0.19.2 and minecraft versionm 26.2

Kodari AI
KodariNov 7 at 8:46 pm 1

This project targets Fabric 26.3. Kodari supports Fabric 26.2, but you’ll need to switch project type to make the mod compatible.

Switch to Fabric 26.2

SuperNova

edit this mod to be compatible with fabric loader 0.19.2 and minecraft versionm 26.2

Kodari AI
KodariNov 7 at 8:49 pm 5

I’ll update the version requirements and check the miner’s code against the 26.2 APIs.

Updated the mod for Minecraft 26.2 and Fabric Loader 0.19.2, including the 26.2-compatible swing call and Fabric API version.

SuperNova

also edit that it should scan the simulation distance of the player, also about safly reaching meant mining block, or building with blocks in inventory to reach the designated ore somehow, also increases speed of player also in command of auto minecraft give list for blocks too so its easy to execute command

Kodari AI
KodariNov 7 at 9:02 pm 7
  1. Expand ore scanning to the player’s simulation distance.

  2. Add routes that can mine or place inventory blocks when needed.

  3. Increase travel speed where the server permits it.

  4. Add block suggestions to the auto-mine command.

  • Scan loaded chunks incrementally, including underground sections.

  • Keep the route search separate so unloaded chunks are never generated.

  • Preserve the existing hazard checks while expanding the search area.

Updated /automine to scan loaded chunks within the server’s simulation distance, suggest block IDs as you type, sprint while travelling, and mine through safe-looking obstructions with the selected item.

Limitations: routing stays at the player’s current elevation and does not place inventory blocks yet. Hazard checks reduce risk but cannot guarantee safety.

SuperNova

bro i said its not important if its exposed or not i just want to reach and mine the block no matter what if its under the simulation distance, no matter how deep its buried or how high its floating, build with anything u have in inventory mine with whatver ur holding

Kodari AI
KodariNov 7 at 9:12 pm 6

I’ll remove the exposed-ore and flat-route limits, then add vertical pathfinding that mines obstructions or uses inventory blocks to reach the target.

Updated /automine start <block> to search loaded chunks within simulation distance, including buried and elevated blocks. It now tries to tunnel, build bridges and stairways, or pillar upward using inventory blocks, while mining with your selected item.

It can still stop if chunks aren’t loaded, hazards block the route, building blocks run out, or the server rejects an action. Only the nearest 64 matching blocks are considered per scan.

SuperNova

it just get stucks while scanning i was instant tracking like using tricks like xray or something but i want scan instant and execution fastest

Kodari AI
KodariNov 7 at 9:18 pm 3
  • Search nearby loaded chunks first and start routing as soon as a match is found.

  • Speed up route planning without freezing the client or bypassing server mining limits.

Updated scanning to check nearby chunks first and start routing as soon as it finds a match, rather than waiting for the entire scan. Route planning now favors faster paths and uses a per-tick time limit to reduce freezing.

It can only detect blocks the server has sent to your client. Server anti-X-ray can hide ores, and mining and movement remain subject to server limits. The route search is also bounded, so some reachable ores may be missed.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
5 612
src/client/java/com/kodari/oreminer/SafeOreMiner.java
package com.kodari.oreminer;

import com.mojang.brigadier.arguments.StringArgumentType;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.command.v2.ClientCommands;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.Identifier;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.ContainerInput;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FallingBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.chunk.status.ChunkStatus;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;

public final class SafeOreMiner implements ClientModInitializer {
    private static final Direction[] HORIZONTAL = {
        Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST
    };
    private static final int MAX_CANDIDATES = 64;
    private static final int MAX_ROUTE_NODES = 30000;
    private Block desired;
    private FabricClientCommandSource source;
    private ClientLevel activeLevel;
    private BlockPos target;
    private List<BlockPos> path = List.of();
    private int pathIndex;
    private BlockPos miningBlock;
    private int mineTicks;
    private int stuckTicks;
    private int placementTicks;
    private double lastX, lastY, lastZ;
    private boolean minerSprinting;

    private BlockPos scanOrigin;
    private int scanRadius, scanCursor;
    private List<ChunkOffset> scanChunks;
    private List<BlockPos> candidates;
    private PriorityQueue<BlockPos> nearestCandidates;
    private int candidateIndex;
    private PriorityQueue<RouteNode> routeQueue;
    private Map<BlockPos, Double> routeCosts;
    private Map<BlockPos, BlockPos> routePrevious;
    private BlockPos routeStart;
    private BlockPos routeGoal;

    private record RouteNode(BlockPos pos, double cost, double score) { }
    private record ChunkOffset(int x, int z) { }

    @Override
    public void onInitializeClient() {
        ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(
            ClientCommands.literal("automine")
                .then(ClientCommands.literal("start")
                    .then(ClientCommands.argument("block", StringArgumentType.word())
                        .suggests((context, builder) -> SharedSuggestionProvider.suggestResource(BuiltInRegistries.BLOCK.keySet(), builder))
                        .executes(context -> start(context.getSource(), StringArgumentType.getString(context, "block")))))
                .then(ClientCommands.literal("stop").executes(context -> {
                    stop(Minecraft.getInstance(), "Auto-miner stopped.");
                    return 1;
                }))
        ));
        ClientTickEvents.START_CLIENT_TICK.register(this::tick);
    }

    private int start(FabricClientCommandSource commandSource, String name) {
        Minecraft client = Minecraft.getInstance();
        Identifier id = Identifier.tryParse(name);
        Block block = id == null ? null : BuiltInRegistries.BLOCK.getOptional(id).orElse(null);
        if (client.player == null || client.level == null || client.gameMode == null) {
            commandSource.sendError(Component.literal("Join a world before starting the auto-miner."));
            return 0;
        }
        if (block == null || block == Blocks.AIR) {
            commandSource.sendError(Component.literal("Unknown block ID: " + name));
            return 0;
        }
        if (desired != null) stop(client, null);
        desired = block;
        source = commandSource;
        activeLevel = client.level;
        resetSearch();
        commandSource.sendFeedback(Component.literal("Searching loaded chunks for " + id + ". Use /automine stop to cancel."));
        return 1;
    }

    private void stop(Minecraft client, String message) {
        releaseMovement(client);
        if (miningBlock != null && client.gameMode != null) client.gameMode.stopDestroyBlock();
        if (message != null && source != null) source.sendFeedback(Component.literal(message));
        desired = null;
        source = null;
        activeLevel = null;
        miningBlock = null;
        resetSearch();
    }

    private void resetSearch() {
        target = null;
        path = List.of();
        pathIndex = 0;
        scanOrigin = null;
        scanChunks = null;
        candidates = null;
        nearestCandidates = null;
        routeQueue = null;
        routeCosts = null;
        routePrevious = null;
        routeGoal = null;
        mineTicks = 0;
        stuckTicks = 0;
        placementTicks = 0;
    }

    private void releaseMovement(Minecraft client) {
        client.options.keyUp.setDown(false);
        client.options.keyJump.setDown(false);
        if (minerSprinting && client.player != null) client.player.setSprinting(false);
        minerSprinting = false;
    }

    private void tick(Minecraft client) {
        if (desired == null) return;
        if (client.player == null || client.level != activeLevel || client.gameMode == null) {
            stop(client, null);
            return;
        }
        if (client.gui.screen() != null || client.gui.overlay() != null) {
            releaseMovement(client);
            if (miningBlock != null) client.gameMode.stopDestroyBlock();
            miningBlock = null;
            mineTicks = 0;
            return;
        }
        ClientLevel level = client.level;
        if (target == null) {
            releaseMovement(client);
            if (candidates == null || candidateIndex >= candidates.size()) {
                if (scanChunks != null && scanCursor >= scanChunks.size()) {
                    stop(client, "No reachable matching block found in loaded chunks. Try moving closer or supplying building blocks.");
                    return;
                }
                scan(client);
                return;
            }
            findRoute(client);
            return;
        }
        if (!loaded(level, target) || level.getBlockState(target).getBlock() != desired) {
            if (miningBlock != null) client.gameMode.stopDestroyBlock();
            miningBlock = null;
            releaseMovement(client);
            resetSearch();
            return;
        }
        if (pathIndex < path.size()) {
            followPath(client);
            return;
        }
        releaseMovement(client);
        mineBlock(client, target);
    }

    private void scan(Minecraft client) {
        ClientLevel level = client.level;
        if (scanChunks == null) {
            scanOrigin = client.player.blockPosition();
            scanRadius = Math.max(0, level.getServerSimulationDistance());
            scanChunks = new ArrayList<>();
            for (int x = -scanRadius; x <= scanRadius; x++) {
                for (int z = -scanRadius; z <= scanRadius; z++) {
                    scanChunks.add(new ChunkOffset(x, z));
                }
            }