gehfgjmkghj hgjghj

wygeneruj mi moda do minecraft ktory jak wykryje ze kilof ma ponizej 30 uzyc klika w kowadło naprawia kilof diamentami odklada diamenty i kilof na pierwotne miejsce

Kodari AI
KodariOct 13 at 1:57 pm 2
AutoPickaxeRepair
An automatic pickaxe repair system that monitors tool durability. When a pickaxe drops below 30 uses remaining, the mod automatically interacts with an anvil, repairs the pickaxe using diamonds from inventory, and returns both the pickaxe and remaining diamonds to their original inventory slots. Features include configurable durability threshold, automatic anvil detection, and seamless item restoration.

Plan:

  1. Utworzę konfigurację Fabric 1.21.11 oraz klientowy entrypoint.

  2. Dodam automatyczne wykrywanie diamentowego kilofa z mniej niż 30 punktami trwałości, gdy ekran kowadła jest otwarty.

  3. Mod wstawi kilof i jeden diament, odbierze naprawiony kilof i przywróci go oraz resztę diamentów do pierwotnych slotów; przy braku możliwości naprawy cofnie operację.

Utworzyłem klientowego moda Fabric 1.21.11. Gdy otworzysz ekran kowadła, mod wykryje diamentowy kilof z mniej niż 30 punktami trwałości, naprawi go jednym diamentem i odłoży kilof oraz pozostałe diamenty do pierwotnych slotów. Jeśli naprawa się nie powiedzie, spróbuje przywrócić przedmioty.

Kowadło trzeba otworzyć samodzielnie. Do naprawy potrzeba diamentu i wystarczającej liczby poziomów doświadczenia.

gehfgjmkghj hgjghj

a zrob tak zeby bot samemu klikal w kowadło nie przerywajac robienia niczego

Kodari AI
KodariOct 13 at 2:04 pm 1
  1. Sprawdzę obecną automatyzację i dostępne wywołania interakcji z kowadłem.

  2. Ustawię automatyczne szukanie i użycie pobliskiego kowadła, o ile da się to zrobić bez blokowania gry; jeśli GUI kowadła wymaga przerwania aktualnego działania, nie będę udawać, że da się to ominąć.

Nie da się tego zrobić bez przerwania aktualnej akcji przy użyciu zwykłych mechanik Minecrafta. Kowadło wymaga otwarcia serwerowego ekranu i zmiany aktywnego kontenera, co przejmuje sterowanie na czas naprawy.

Obecny mod naprawia kilof automatycznie po otwarciu kowadła. Mogę dodać automatyczne wyszukiwanie i otwieranie pobliskiego kowadła, ale na moment przerwie to grę.

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

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ingame.AnvilScreen;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.screen.AnvilScreenHandler;
import net.minecraft.screen.slot.SlotActionType;

public class AnvilRepairClient implements ClientModInitializer {
    private enum Step {
        IDLE,
        PICK_UP_PICKAXE,
        PLACE_PICKAXE,
        PICK_UP_DIAMONDS,
        PLACE_ONE_DIAMOND,
        RETURN_REMAINING_DIAMONDS,
        WAIT_FOR_RESULT,
        RETURN_REPAIRED_PICKAXE,
        ROLLBACK_PICKAXE,
        RETURN_ROLLED_BACK_PICKAXE,
        ROLLBACK_DIAMONDS,
        RETURN_ROLLED_BACK_DIAMONDS
    }

    private Step step = Step.IDLE;
    private int pickaxeInventoryIndex = -1;
    private int diamondInventoryIndex = -1;
    private int outputWaitTicks;

    @Override
    public void onInitializeClient() {
        ClientTickEvents.END_CLIENT_TICK.register(this::onClientTick);
    }

    private void onClientTick(MinecraftClient client) {
        if (!(client.currentScreen instanceof AnvilScreen anvilScreen)
                || client.player == null
                || client.interactionManager == null) {
            reset();
            return;
        }

        ClientPlayerEntity player = client.player;
        AnvilScreenHandler handler = anvilScreen.getScreenHandler();
        if (player.currentScreenHandler != handler) {
            reset();
            return;
        }

        if (step == Step.IDLE) {
            beginIfReady(player, handler);
            return;
        }

        switch (step) {
            case PICK_UP_PICKAXE -> {
                click(client, handler, inventorySlotId(pickaxeInventoryIndex), 0);
                step = Step.PLACE_PICKAXE;
            }
            case PLACE_PICKAXE -> {
                if (handler.getCursorStack().isOf(Items.DIAMOND_PICKAXE)) {
                    click(client, handler, AnvilScreenHandler.INPUT_1_ID, 0);
                    step = Step.PICK_UP_DIAMONDS;
                }
            }
            case PICK_UP_DIAMONDS -> {
                if (handler.getCursorStack().isEmpty()) {
                    click(client, handler, inventorySlotId(diamondInventoryIndex), 0);
                    step = Step.PLACE_ONE_DIAMOND;
                }
            }
            case PLACE_ONE_DIAMOND -> {
                if (handler.getCursorStack().isOf(Items.DIAMOND)) {
                    click(client, handler, AnvilScreenHandler.INPUT_2_ID, 1);
                    step = Step.RETURN_REMAINING_DIAMONDS;
                }
            }
            case RETURN_REMAINING_DIAMONDS -> {
                ItemStack cursorStack = handler.getCursorStack();
                if (cursorStack.isEmpty()) {
                    step = Step.WAIT_FOR_RESULT;
                } else if (cursorStack.isOf(Items.DIAMOND)) {
                    click(client, handler, inventorySlotId(diamondInventoryIndex), 0);
                    step = Step.WAIT_FOR_RESULT;
                }
            }
            case WAIT_FOR_RESULT -> waitForResult(client, player, handler);
            case RETURN_REPAIRED_PICKAXE -> {
                if (handler.getCursorStack().isOf(Items.DIAMOND_PICKAXE)) {
                    click(client, handler, inventorySlotId(pickaxeInventoryIndex), 0);
                    reset();
                }
            }
            case ROLLBACK_PICKAXE -> {
                if (handler.getCursorStack().isEmpty() && handler.getSlot(AnvilScreenHandler.INPUT_1_ID).hasStack()) {
                    click(client, handler, AnvilScreenHandler.INPUT_1_ID, 0);
                    step = Step.RETURN_ROLLED_BACK_PICKAXE;
                }
            }
            case RETURN_ROLLED_BACK_PICKAXE -> {
                if (handler.getCursorStack().isOf(Items.DIAMOND_PICKAXE)) {
                    click(client, handler, inventorySlotId(pickaxeInventoryIndex), 0);
                    step = Step.ROLLBACK_DIAMONDS;
                }
            }
            case ROLLBACK_DIAMONDS -> {
                if (handler.getCursorStack().isEmpty() && handler.getSlot(AnvilScreenHandler.INPUT_2_ID).hasStack()) {
                    click(client, handler, AnvilScreenHandler.INPUT_2_ID, 0);
                    step = Step.RETURN_ROLLED_BACK_DIAMONDS;
                }
            }
            case RETURN_ROLLED_BACK_DIAMONDS -> {
                if (handler.getCursorStack().isOf(Items.DIAMOND)) {
                    click(client, handler, inventorySlotId(diamondInventoryIndex), 0);
                    reset();
                }
            }
            case IDLE -> {
            }
        }
    }

    private void beginIfReady(ClientPlayerEntity player, AnvilScreenHandler handler) {
        if (!handler.getCursorStack().isEmpty()
                || handler.getSlot(AnvilScreenHandler.INPUT_1_ID).hasStack()
                || handler.getSlot(AnvilScreenHandler.INPUT_2_ID).hasStack()) {
            return;
        }

        PlayerInventory inventory = player.getInventory();
        for (int i = 0; i < PlayerInventory.MAIN_SIZE; i++) {
            ItemStack stack = inventory.getStack(i);
            if (stack.isOf(Items.DIAMOND_PICKAXE) && stack.getMaxDamage() - stack.getDamage() < 30) {
                pickaxeInventoryIndex = i;
                break;
            }
        }

        if (pickaxeInventoryIndex < 0) {
            return;
        }

        for (int i = 0; i < PlayerInventory.MAIN_SIZE; i++) {
            if (inventory.getStack(i).isOf(Items.DIAMOND)) {
                diamondInventoryIndex = i;
                break;
            }
        }

        if (diamondInventoryIndex < 0) {
            pickaxeInventoryIndex = -1;
            return;
        }

        step = Step.PICK_UP_PICKAXE;
    }

    private void waitForResult(MinecraftClient client, ClientPlayerEntity player, AnvilScreenHandler handler) {
        if (handler.getSlot(AnvilScreenHandler.OUTPUT_ID).hasStack()) {
            int levelCost = handler.getLevelCost();
            if (levelCost > 0 && (player.isInCreativeMode() || player.experienceLevel >= levelCost)) {
                click(client, handler, AnvilScreenHandler.OUTPUT_ID, 0);
                step = Step.RETURN_REPAIRED_PICKAXE;
                return;
            }
        }

        if (++outputWaitTicks >= 20) {
            step = Step.ROLLBACK_PICKAXE;
        }
    }

    private void click(MinecraftClient client, AnvilScreenHandler handler, int slotId, int button) {
        client.interactionManager.clickSlot(handler.syncId, slotId, button, SlotActionType.PICKUP, client.player);
    }

    private static int inventorySlotId(int inventoryIndex) {
        return inventoryIndex < PlayerInventory.HOTBAR_SIZE ? inventoryIndex + 30 : inventoryIndex - 6;
    }

    private void reset() {
        step = Step.IDLE;
        pickaxeInventoryIndex = -1;
        diamondInventoryIndex = -1;
        outputWaitTicks = 0;
    }
}