Khosrel

Make me a auto sheild breaker mod that swaps to axe and back to sword when detects a shield make it so the delay can be adjusted to avoid suspicion make it version 1.21.11

Kodari AI
KodariOct 28 at 7:38 am 2
AutoShieldBreaker
An automatic shield-breaking utility mod for Minecraft 1.21.11 that detects when an opponent raises a shield and instantly swaps the player's weapon from sword to axe, performs the attack, then swaps back to the original weapon. Features a configurable delay system to simulate human-like reaction times, making the swap behavior less detectable by other players. The mod continuously monitors combat state, automatically triggers the weapon swap sequence when a shield is detected, and includes adjustable timing parameters for both the initial swap and the return swap to maintain natural gameplay appearance.

I’ll create a client-side Fabric 1.21.11 mod with shield detection, axe/sword swapping, and adjustable timing via keybinds.

Created the Fabric 1.21.11 client mod. When you attack a player actively blocking with a shield, it switches to a hotbar axe, waits, attacks, then restores your previous slot.

  • F8: toggle the feature

  • [ / ]: decrease or increase the delay by one tick (default 4; range 0–40)

  • The delay resets to 4 ticks when the game restarts. No new survival items are added.

Khosrel

Make a gui and the hotkey for the gui is g and to enable the mod hotkey is k

Kodari AI
KodariOct 28 at 7:45 am 2
  1. Add a G-key owo-ui settings screen for the toggle and adjustable delay.

  2. Change the mod toggle hotkey to K and register the new screen/library dependency.

Added the settings GUI: press G to open it and K to toggle the mod. The GUI lets you enable/disable automatic axe swapping and set the attack delay from 0–40 ticks. The existing [ / ] delay hotkeys still work.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
8 357
src/client/java/com/kodari/shieldbreaker/ShieldBreakerClient.java
package com.kodari.shieldbreaker;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.AxeItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
import org.lwjgl.glfw.GLFW;

public final class ShieldBreakerClient implements ClientModInitializer {
    private static final int MIN_DELAY_TICKS = 0;
    private static final int MAX_DELAY_TICKS = 40;
    private static final KeyBinding.Category CATEGORY = KeyBinding.Category.create(Identifier.of("shieldbreaker", "main"));

    private static final KeyBinding TOGGLE_KEY = KeyBindingHelper.registerKeyBinding(
            new KeyBinding("key.shieldbreaker.toggle", GLFW.GLFW_KEY_K, CATEGORY));
    private static final KeyBinding OPEN_GUI_KEY = KeyBindingHelper.registerKeyBinding(
            new KeyBinding("key.shieldbreaker.open_gui", GLFW.GLFW_KEY_G, CATEGORY));
    private static final KeyBinding INCREASE_DELAY_KEY = KeyBindingHelper.registerKeyBinding(
            new KeyBinding("key.shieldbreaker.delay_increase", GLFW.GLFW_KEY_RIGHT_BRACKET, CATEGORY));
    private static final KeyBinding DECREASE_DELAY_KEY = KeyBindingHelper.registerKeyBinding(
            new KeyBinding("key.shieldbreaker.delay_decrease", GLFW.GLFW_KEY_LEFT_BRACKET, CATEGORY));

    private static boolean enabled = true;
    private static int delayTicks = 4;
    private static PlayerEntity pendingTarget;
    private static int originalSlot = -1;
    private static int axeSlot = -1;
    private static int attackCountdown;
    private static int restoreCountdown;
    private static boolean attackSent;
    private static boolean performingDeferredAttack;

    @Override
    public void onInitializeClient() {
        AttackEntityCallback.EVENT.register((player, world, hand, target, hitResult) -> {
            MinecraftClient client = MinecraftClient.getInstance();
            if (!world.isClient() || player != client.player || !enabled) {
                return ActionResult.PASS;
            }
            if (performingDeferredAttack) {
                return ActionResult.PASS;
            }
            if (pendingTarget != null) {
                return ActionResult.FAIL;
            }
            if (!(target instanceof PlayerEntity blockingPlayer) || !blockingPlayer.isBlocking()) {
                return ActionResult.PASS;
            }

            ItemStack blockingItem = blockingPlayer.getBlockingItem();
            if (blockingItem == null || !blockingItem.isOf(Items.SHIELD)) {
                return ActionResult.PASS;
            }

            PlayerInventory inventory = client.player.getInventory();
            if (inventory.getSelectedStack().getItem() instanceof AxeItem) {
                return ActionResult.PASS;
            }

            int foundAxeSlot = -1;
            for (int slot = 0; slot < 9; slot++) {
                if (inventory.getStack(slot).getItem() instanceof AxeItem) {
                    foundAxeSlot = slot;
                    break;
                }
            }
            if (foundAxeSlot < 0) {
                return ActionResult.PASS;
            }

            originalSlot = inventory.getSelectedSlot();
            axeSlot = foundAxeSlot;
            pendingTarget = blockingPlayer;
            attackCountdown = delayTicks;
            restoreCountdown = 0;
            attackSent = false;
            inventory.setSelectedSlot(axeSlot);
            return ActionResult.FAIL;
        });

        ClientTickEvents.END_CLIENT_TICK.register(ShieldBreakerClient::tick);
    }

    private static void tick(MinecraftClient client) {
        if (OPEN_GUI_KEY.wasPressed() && client.currentScreen == null) {
            client.setScreen(new ShieldBreakerScreen());
        }

        if (client.currentScreen == null) {
            if (TOGGLE_KEY.wasPressed()) {
                enabled = !enabled;
                sendStatus(client, "Auto shield breaker " + (enabled ? "enabled" : "disabled"));
            }
            if (INCREASE_DELAY_KEY.wasPressed()) {
                delayTicks = Math.min(MAX_DELAY_TICKS, delayTicks + 1);
                sendStatus(client, "Shield-break delay: " + delayTicks + " ticks");
            }
            if (DECREASE_DELAY_KEY.wasPressed()) {
                delayTicks = Math.max(MIN_DELAY_TICKS, delayTicks - 1);
                sendStatus(client, "Shield-break delay: " + delayTicks + " ticks");
            }
        }

        if (client.player == null || client.interactionManager == null) {
            clearPending(client);
            return;
        }
        if (client.currentScreen != null) {
            clearPending(client);
            return;
        }
        if (pendingTarget == null) {
            return;
        }

        if (!attackSent) {
            if (attackCountdown > 0) {
                attackCountdown--;
                if (attackCountdown > 0) {
                    return;
                }
            }

            PlayerInventory inventory = client.player.getInventory();
            if (inventory.getSelectedSlot() != axeSlot) {
                inventory.setSelectedSlot(axeSlot);
            }

            attackSent = true;
            performingDeferredAttack = true;
            try {
                client.interactionManager.attackEntity(client.player, pendingTarget);
            } finally {
                performingDeferredAttack = false;
                restoreCountdown = 1;
            }
            return;
        }

        if (restoreCountdown > 0) {
            restoreCountdown--;
        }
        if (restoreCountdown == 0) {
            clearPending(client);
        }
    }

    private static void sendStatus(MinecraftClient client, String message) {
        if (client.player != null) {
            client.player.sendMessage(Text.literal(message), true);
        }
    }

    private static void clearPending(MinecraftClient client) {
        if (client.player != null && originalSlot >= 0 && axeSlot >= 0) {
            PlayerInventory inventory = client.player.getInventory();
            if (inventory.getSelectedSlot() == axeSlot) {
                inventory.setSelectedSlot(originalSlot);
            }
        }
        pendingTarget = null;
        originalSlot = -1;
        axeSlot = -1;
        attackCountdown = 0;
        restoreCountdown = 0;
        attackSent = false;
        performingDeferredAttack = false;
    }

    static boolean isEnabled() {
        return enabled;
    }

    static void setEnabled(boolean value) {
        enabled = value;
    }

    static int getDelayTicks() {
        return delayTicks;
    }

    static void setDelayTicks(int value) {
        delayTicks = Math.max(MIN_DELAY_TICKS, Math.min(MAX_DELAY_TICKS, value));
    }
}