S

Make a 1.21.11 mod that when ur holding a mace and u reach to an opponent it hits the as soon as its close enough to hit if the are holding a shield then hit with with the axe only if ur already holding them (this works on all entities) it does not include aim assist and it must have a customizable keybind to disable and enable it (it only works if your not wearing a elytra)

Kodari AI
KodariOct 15 at 1:16 am 2
AutoMeleeAssist
AutoMeleeAssist is a Fabric mod for Minecraft 1.21.11 that automatically attacks nearby entities when holding a mace, striking as soon as they enter reach range. If the target holds a shield, it switches to an axe for shield-breaking, but only if an axe is already in the offhand. Works on all entities, features a customizable keybind to toggle the mod on/off, and disables itself while the player wears an elytra. No aim assist included.
  1. Add a client-only Fabric 1.21.11 mod with a customizable toggle key (default K).

  2. Attack only the entity under the crosshair: use a held mace on any entity, or a held axe against a shield-holder; skip while wearing an elytra.

  3. Add the split-source-set project setup, mod metadata, and keybind localization.

Added the client-side 1.21.11 mod. It attacks only the entity under your crosshair—no aim assist—with a held mace, or with an axe already in your main hand when the target is holding a shield. It pauses while you’re wearing an elytra.

Toggle is K by default and can be rebound in Minecraft’s Controls settings.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
6 149
src/client/java/com/kodari/maceauto/MaceAutoAttackClient.java
package com.kodari.maceauto;

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.minecraft.client.option.KeyBinding;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.tag.ItemTags;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.EntityHitResult;

public class MaceAutoAttackClient implements ClientModInitializer {
    private static final String MOD_ID = "maceauto";
    private static final KeyBinding.Category CATEGORY = KeyBinding.Category.create(Identifier.of(MOD_ID, "main"));
    private static KeyBinding toggleKey;
    private static boolean enabled = true;

    @Override
    public void onInitializeClient() {
        toggleKey = KeyBindingHelper.registerKeyBinding(
                new KeyBinding("key.maceauto.toggle", 75, CATEGORY)
        );

        ClientTickEvents.END_CLIENT_TICK.register(MaceAutoAttackClient::onEndTick);
    }

    private static void onEndTick(MinecraftClient client) {
        while (toggleKey.wasPressed()) {
            enabled = !enabled;
        }

        if (!enabled || client.player == null || client.interactionManager == null
                || !(client.crosshairTarget instanceof EntityHitResult entityHit)) {
            return;
        }

        PlayerEntity player = client.player;
        if (player.getEquippedStack(EquipmentSlot.CHEST).isOf(Items.ELYTRA)) {
            return;
        }

        ItemStack heldStack = player.getMainHandStack();
        boolean shouldAttack = heldStack.isOf(Items.MACE);

        if (!shouldAttack && heldStack.isIn(ItemTags.AXES) && entityHit.getEntity() instanceof LivingEntity target) {
            shouldAttack = target.getMainHandStack().isOf(Items.SHIELD)
                    || target.getOffHandStack().isOf(Items.SHIELD);
        }

        if (shouldAttack) {
            client.interactionManager.attackEntity(player, entityHit.getEntity());
            player.swingHand(Hand.MAIN_HAND);
        }
    }
}