Kris Chand

For Minecraft JAVA 26.3, fabric loader version 0.19.5.

📎 1 file 2,745 chars
📄
pasted-code-1793458860151.txt
txt 35 lines
▶
Create a Minecraft Java Edition 26.3 Fabric mod named **CraftPilot**. Its purpose is to automatically craft selected items using the player's available inventory materials.

### 1. Crafting Setup GUI
- Open the GUI using one customizable single-key hotkey (default: K).
- Provide a clean, small interface with an item search bar, item suggestions, and Minecraft item icons.
- Let players select any craftable item and choose a crafting quantity.
- Provide two quantity options: a custom number (e.g. 10, 32, 64) or MAX.
- Save the selected item and crafting target until completed or cancelled.

### 2. Automatic Crafting
- When the player opens a crafting table, pressing the configured crafting shortcut should start the saved crafting task.
- Automatically calculate the required ingredients and fill the crafting grid.
- Support recipes requiring multiple crafting stages. For example, crafting sticks from oak logs should automatically convert logs into planks before making sticks.
- Craft repeatedly until the requested quantity is reached, ingredients run out, or the player cancels.
- MAX should craft the greatest possible quantity using available materials.
- Never exceed the requested quantity.
- If ingredients are insufficient for the exact target, craft as many complete recipes as possible.

### 3. Inventory Management
- Automatically collect crafted outputs into the player's inventory and combine compatible stacks.
- If inventory space becomes insufficient, provide an optional automatic space-making feature.
- Allow players to select which unwanted items can be discarded to make room.
- Never discard equipment, enchanted items, valuable items, or protected items automatically.
- Stop safely and explain the problem if space cannot be made.

### 4. Controls and Settings
- GUI opening must use exactly one customizable key.
- Crafting execution must have a separate customizable shortcut supporting combinations such as Shift + K, Ctrl + R, or sequential combinations such as Shift + K → A → B.
- Include an easy keybinding editor with conflict detection.
- Allow players to pause, cancel, and view crafting progress.

### Technical Requirements
Use actual Minecraft recipes and crafting mechanics. Do not spawn items, bypass recipes, or duplicate materials. Support single-player and multiplayer using server-accepted crafting interactions. Save player settings and pending crafting tasks. Use Minecraft 26.3-compatible Fabric APIs and Java 25+. Check the current official Fabric development versions before choosing dependencies.

Build the complete project, compile it, fix errors, and provide the working JAR and full source code. Test the crafting process before claiming it works.
Kodari AI
KodariOct 31 at 3:21 pm 5
CraftPilot
An automatic crafting assistant mod for Minecraft Fabric 26.3. Players configure a target item and quantity via a searchable GUI opened with a customizable hotkey. When interacting with a crafting table, the mod calculates multi-stage recipe requirements, fills the crafting grid, and repeatedly crafts until the target is met, materials run out, or cancelled. It manages inventory by collecting outputs, combining stacks, and optionally discarding user-selected unwanted items when space is insufficient, while protecting equipment and valuable items. Features separate keybindings for GUI and crafting execution with conflict detection, progress display, pause/cancel controls, and persistent settings.
  1. Build CraftPilot’s Fabric 26.3 project and client setup.

  2. Add an owo-ui item/quantity selector and configurable shortcuts.

  3. Implement recipe-aware crafting through accepted crafting-menu clicks, then persist task/settings.

Created the CraftPilot Fabric 26.3 project and source. It includes an owo-ui item search and quantity selector, a configurable K opening key, and a separate crafting shortcut that can capture a modifier chord or a three-key sequence. Crafting runs through the server’s recipe manager and vanilla crafting menu, including recursive intermediate recipes, with pause, resume, cancel, and progress status.

Limitations: automatic discarding is not implemented; if inventory space runs out, CraftPilot stops without deleting items. I also could not run a live in-game crafting test here, so I can’t claim the process has been tested in-game.

To compile and download the jar in Kodari:

  1. Click Compile in the top bar (on phone: ⋮ → Compile Project).

  2. Click Compile in the window.

  3. When it succeeds, click Download on the build.

Kris Chand

make it a client side mod.

Kodari AI
KodariOct 31 at 4:19 pm 3
  1. Remove server entrypoints and CraftPilot-specific networking.

  2. Run the crafting task client-side using the player’s synchronized recipe book and vanilla menu clicks.

  3. Keep task progress, controls, and settings local to the client.

CraftPilot is now a client-only mod: the server entrypoint and custom networking were removed, and crafting uses the client’s synchronized recipe book and vanilla menu interactions accepted by the server.

The item list is limited to recipes currently available in the player’s recipe book. I haven’t live-tested the crafting flow in-game.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
9 977
src/client/java/com/kodari/craftpilot/client/CraftPilotClient.java
package com.kodari.craftpilot.client;

import com.mojang.blaze3d.platform.InputConstants;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keymapping.v1.KeyMappingHelper;
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
import net.fabricmc.fabric.api.client.screen.v1.ScreenKeyboardEvents;
import net.minecraft.client.ClientRecipeBook;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.CraftingScreen;
import net.minecraft.client.gui.screens.recipebook.RecipeCollection;
import net.minecraft.client.input.KeyEvent;
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.Holder;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.Identifier;
import net.minecraft.util.context.ContextMap;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.ContainerInput;
import net.minecraft.world.inventory.CraftingMenu;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.display.RecipeDisplayEntry;
import net.minecraft.world.item.crafting.display.RecipeDisplayId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public final class CraftPilotClient implements ClientModInitializer {
    private static final String MOD_ID = "craftpilot";
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
    private static final int MODIFIER_MASK = InputConstants.MOD_SHIFT | InputConstants.MOD_CONTROL | InputConstants.MOD_ALT | InputConstants.MOD_SUPER;
    private static final int MAX_RECURSION_DEPTH = 16;
    private static final int ACTION_TIMEOUT_TICKS = 60;

    private static KeyMapping openScreenKey;
    private static String status = "Choose an item, then open a crafting table.";
    private static CraftTask task;
    private static int captureLength;
    private static int captureIndex;
    private static int[] captureKeys;
    private static int[] captureModifiers;
    private static String[] captureNames;
    private static int sequenceIndex;
    private static long lastSequenceInput;

    @Override
    public void onInitializeClient() {
        CraftPilotConfig.load();
        openScreenKey = KeyMappingHelper.registerKeyMapping(new KeyMapping(
                "key.craftpilot.open", InputConstants.Type.KEYBOARD, InputConstants.KEY_K, KeyMapping.Category.MISC
        ));

        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            while (openScreenKey.consumeClick()) {
                if (!(client.gui.screen() instanceof CraftPilotScreen)) {
                    client.gui.setScreen(new CraftPilotScreen());
                }
            }
            tickTask(client);
        });

        ScreenEvents.AFTER_INIT.register((client, screen, scaledWidth, scaledHeight) ->
                ScreenKeyboardEvents.beforeKeyPress(screen).register((currentScreen, event) -> handleKey(currentScreen, event)));

        if (CraftPilotConfig.pendingItem != null) {
            status = "Saved task. Open a crafting table and press the crafting shortcut.";
        }
    }

    static List<Identifier> recipeItems() {
        Set<Identifier> ids = new HashSet<>();
        for (RecipeDisplayEntry entry : recipeEntries()) {
            for (ItemStack result : entry.resultItems(ContextMap.EMPTY)) {
                if (!result.isEmpty()) {
                    ids.add(BuiltInRegistries.ITEM.getKey(result.getItem()));
                }
            }
        }
        return ids.stream().sorted().toList();
    }

    static String status() {
        return status;
    }

    static Item resolveItem(Identifier id) {
        return BuiltInRegistries.ITEM.get(id).map(Holder::value).orElse(null);
    }

    static void saveTask() {
        if (task != null) {
            status = "Cancel the current task before saving another.";
            return;
        }

        CraftPilotConfig.pendingItem = CraftPilotConfig.selectedItem;
        CraftPilotConfig.pendingQuantity = CraftPilotConfig.maxQuantity ? -1 : CraftPilotConfig.quantity;
        CraftPilotConfig.save();
        status = CraftPilotConfig.pendingItem == null
                ? "Select an item in CraftPilot first."
                : "Task saved. Open a crafting table and press " + CraftPilotConfig.shortcutDescription() + ".";
    }

    static void startTask() {
        Minecraft client = Minecraft.getInstance();
        if (CraftPilotConfig.pendingItem == null) {
            if (CraftPilotConfig.selectedItem == null) {
                status = "Select an item in CraftPilot first.";
                return;
            }
            CraftPilotConfig.pendingItem = CraftPilotConfig.selectedItem;
            CraftPilotConfig.pendingQuantity = CraftPilotConfig.maxQuantity ? -1 : CraftPilotConfig.quantity;
            CraftPilotConfig.save();
        }

        if (!(client.gui.screen() instanceof CraftingScreen screen) || client.player == null || client.gameMode == null) {
            status = "Task saved. Open a crafting table and press the crafting shortcut.";
            return;
        }

        Item target = resolveItem(CraftPilotConfig.pendingItem);
        if (target == null || recipeEntriesFor(target).isEmpty()) {
            status = "That item has no recipe unlocked in your recipe book.";
            return;
        }

        CraftingMenu menu = screen.getMenu();
        if (task != null && task.target == target && task.requested == CraftPilotConfig.pendingQuantity) {
            task.paused = false;
            status = "Crafting resumed.";
            return;
        }
        if (menu.getInputGridSlots().stream().anyMatch(Slot::hasItem)) {
            status = "Empty the crafting grid before starting CraftPilot.";
            return;
        }
        if (!menu.getCarried().isEmpty()) {
            status = "Empty your cursor before starting CraftPilot.";
            return;
        }

        task = new CraftTask(target, CraftPilotConfig.pendingQuantity, countItem(client.player.getInventory(), target));
        status = task.requested == -1 ? "Crafting MAX." : "Crafting toward " + task.requested + " items.";
    }

    static void pauseTask() {
        if (task == null) {
            status = "There is no active task to pause.";
            return;
        }
        task.paused = true;
        status = "Task paused. Use Resume when ready.";
    }

    static void resumeTask() {
        if (task == null) {
            startTask();
            return;
        }
        task.paused = false;
        status = "Task resumed.";
    }

    static void cancelTask() {
        task = null;
        CraftPilotConfig.pendingItem = null;
        CraftPilotConfig.pendingQuantity = 0;
        CraftPilotConfig.save();
        status = "Task cancelled.";
    }

    static void beginCapture(int steps) {
        captureLength = steps;
        captureIndex = 0;
        captureKeys = new int[steps];
        captureModifiers = new int[steps];
        captureNames = new String[steps];
        status = steps == 1 ? "Press the key chord to use for crafting." : "Press the three shortcut steps in order.";
    }

    private static void handleKey(Screen screen, KeyEvent event) {
        if (captureLength > 0 && screen instanceof CraftPilotScreen) {
            if (isModifierKey(event.key())) {
                return;
            }

            int modifiers = event.modifiers() & MODIFIER_MASK;