S

Make a 1.21.11 mod that whenever ur holding a axe and ur 3 or less blocks away from and opponent and looking at the it instantly hits for u but u must have it in ur hand and be 3 or less away from ur opponent the axe does not need to be fully charged up it will attack even if u just took it out and it must always try to hit as soon as possibly but it only hits once after registering a hit with a cooldown of 5 seconds the player could still hit eith the axe during this period

Kodari AI
KodariOct 15 at 3:32 am 1
AutoAxeStrike
Adds an automatic axe attack mechanic. When holding an axe and looking at an opponent within 3 blocks, the mod instantly performs a hit without requiring a charge-up. The attack triggers as soon as possible upon line-of-sight and proximity, with a 5-second cooldown between automatic strikes. Manual axe attacks remain functional during the cooldown period, allowing continuous player-controlled combat.
  1. Add a client tick handler that auto-attacks the targeted player within 3 blocks while an axe is in the main hand.

  2. Gate only automatic attacks with a 5-second cooldown; keep normal manual attacks untouched.

  3. Add the Fabric 1.21.11 project configuration and client entrypoint.

Added the Auto Axe client mod. It sends an attack when you’re aiming at another player within 3 blocks and holding an axe in your main hand. Automatic attacks have a 5-second cooldown; manual attacks remain available during it. The attack isn’t blocked while the axe is uncharged, though damage still follows vanilla cooldown scaling.

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

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.AxeItem;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.EntityHitResult;

public final class AutoAxeClient implements ClientModInitializer {
    private static final long AUTO_ATTACK_COOLDOWN_NANOS = 5_000_000_000L;

    private static long lastAutoAttackNanos;
    private static boolean hasAutoAttacked;

    @Override
    public void onInitializeClient() {
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            if (client.player == null || client.interactionManager == null || client.currentScreen != null) {
                return;
            }

            ClientPlayerEntity player = client.player;
            if (!(player.getMainHandStack().getItem() instanceof AxeItem)) {
                return;
            }

            if (!(client.crosshairTarget instanceof EntityHitResult hitResult)
                    || !(hitResult.getEntity() instanceof PlayerEntity target)
                    || target == player
                    || player.distanceTo(target) > 3.0F) {
                return;
            }

            long now = System.nanoTime();
            if (hasAutoAttacked && now - lastAutoAttackNanos < AUTO_ATTACK_COOLDOWN_NANOS) {
                return;
            }

            client.interactionManager.attackEntity(player, target);
            player.swingHand(Hand.MAIN_HAND);
            lastAutoAttackNanos = now;
            hasAutoAttacked = true;
        });
    }
}