Create complete client-side Fabric 26.3 Java mod Auto Mace with Gradle project, fabric.mod.json, compatible dependencies and Java version. Implement closest selected living entity detection within configurable range, predictive tracking/aim while airborne, and automatic mace attacks only at valid reachable selected targets and appropriate smash conditions; respect server-authoritative reach and do not attack unrelated entities. Z toggles, HUD with status/selection/current target/targeting status and HUD toggle. Client chat commands /automace mob <player|zombie|skeleton|creeper|warden|enderman|spider|witch|iron_golem|all|clear>, suggestions, invalid input feedback, persistent selection. Configuration screen accessible via a keybinding, with range, aim, attack, tracking, activation key, selection display, enabled and HUD options; persist settings. Use Fabric keybinding, client command and HUD APIs appropriate to 26.3; avoid unnecessary mixins and CPU overhead. Provide README with build and usage instructions, limitations and server authority. Implement feature code only, no tests. Inspect available project environment and use appropriate current APIs; do not assert runtime verification.

Kodari AI
KodariToday at 6:46 pm 5
AutoMaceMod
Client-side Fabric mod that automatically targets and attacks the closest selected living entity with a mace while airborne. Features configurable range, predictive tracking, and smash-condition detection. Toggle with Z key, HUD showing status and current target, client commands for entity selection, and a full configuration screen with persistent settings. Respects server-authoritative reach and avoids attacking unrelated entities.
  • Add client-side targeting, predictive aim, and reach-checked smash attacks.

  • Add persistent settings, keybindings, commands, and a status HUD.

  • Include the Gradle project and usage instructions.

Created the Auto Mace client mod with targeting, predictive aim, smash checks, persistent settings, commands, keybindings, and HUD.

Use /automace mob <type> to select targets, then hold a mace and press Z to enable it. Press G for settings or V to toggle the HUD. The server remains authoritative over attacks and reach.

The project has not been runtime-verified.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
README.md
settings.gradle
Code
9 316
src/client/java/com/automace/client/AutoMace.java
package com.automace.client;

import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.brigadier.arguments.StringArgumentType;
import java.util.List;
import java.util.Locale;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.command.v2.ClientCommands;
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.rendering.v1.hud.HudElementRegistry;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.Identifier;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.MaceItem;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.Vec3;

public class AutoMace implements ClientModInitializer {
    private static final List<String> CHOICES = List.of("player", "zombie", "skeleton", "creeper", "warden", "enderman", "spider", "witch", "iron_golem", "all", "clear");
    public static KeyMapping toggleKey;
    private static KeyMapping settingsKey;
    private static KeyMapping hudKey;
    private static LivingEntity target;
    private static String status = "Disabled";

    @Override
    public void onInitializeClient() {
        AutoMaceConfig.HANDLER.load();
        AutoMaceConfig c = AutoMaceConfig.get();
        if (c.activationKey == null) c.activationKey = AutoMaceConfig.ActivationKey.Z;
        if (c.selection == null || !CHOICES.contains(c.selection)) c.selection = "clear";
        if (!Float.isFinite(c.range)) c.range = 6.0f;
        c.range = Math.max(1.0f, Math.min(16.0f, c.range));
        toggleKey = KeyMappingHelper.registerKeyMapping(new KeyMapping("key.automace.toggle", InputConstants.Type.KEYBOARD, c.activationKey.code, KeyMapping.Category.MISC));
        settingsKey = KeyMappingHelper.registerKeyMapping(new KeyMapping("key.automace.settings", InputConstants.Type.KEYBOARD, InputConstants.KEY_G, KeyMapping.Category.MISC));
        hudKey = KeyMappingHelper.registerKeyMapping(new KeyMapping("key.automace.hud", InputConstants.Type.KEYBOARD, InputConstants.KEY_V, KeyMapping.Category.MISC));
        ClientTickEvents.END_CLIENT_TICK.register(AutoMace::tick);
        ClientCommandRegistrationCallback.EVENT.register((dispatcher, registry) -> dispatcher.register(
                ClientCommands.literal("automace").then(ClientCommands.literal("mob")
                        .then(ClientCommands.argument("type", StringArgumentType.word())
                                .suggests((context, builder) -> {
                                    String remaining = builder.getRemaining().toLowerCase(Locale.ROOT);
                                    CHOICES.stream().filter(s -> s.startsWith(remaining)).forEach(builder::suggest);
                                    return builder.buildFuture();
                                })
                                .executes(context -> {
                                    String choice = StringArgumentType.getString(context, "type").toLowerCase(Locale.ROOT);
                                    if (!CHOICES.contains(choice)) {
                                        context.getSource().sendFeedback(Component.literal("Invalid target. Choose: " + String.join(", ", CHOICES)));
                                        return 0;
                                    }
                                    c.selection = choice;
                                    target = null;
                                    AutoMaceConfig.save();
                                    context.getSource().sendFeedback(Component.literal("Auto Mace selection: " + choice));
                                    return 1;
                                })))));
        HudElementRegistry.addLast(Identifier.fromNamespaceAndPath("automace", "status"), (graphics, delta) -> {
            if (!c.hud) return;
            Minecraft mc = Minecraft.getInstance();
            if (mc.player == null) return;
            graphics.text(mc.font, "Auto Mace: " + (c.enabled ? "ON" : "OFF"), 6, 6, 0xFFFFFFFF, true);
            graphics.text(mc.font, "Selection: " + c.selection, 6, 17, 0xFFFFFFFF, true);
            graphics.text(mc.font, "Target: " + (target == null ? "none" : target.getName().getString()), 6, 28, 0xFFFFFFFF, true);
            graphics.text(mc.font, "Status: " + status, 6, 39, 0xFFFFFFFF, true);
        });
    }

    private static boolean selected(Entity e, String selection) {
        return switch (selection) {
            case "all" -> true;
            case "player" -> e.getType() == EntityTypes.PLAYER;
            case "zombie" -> e.getType() == EntityTypes.ZOMBIE;
            case "skeleton" -> e.getType() == EntityTypes.SKELETON;
            case "creeper" -> e.getType() == EntityTypes.CREEPER;
            case "warden" -> e.getType() == EntityTypes.WARDEN;
            case "enderman" -> e.getType() == EntityTypes.ENDERMAN;
            case "spider" -> e.getType() == EntityTypes.SPIDER;
            case "witch" -> e.getType() == EntityTypes.WITCH;
            case "iron_golem" -> e.getType() == EntityTypes.IRON_GOLEM;
            default -> false;
        };
    }

    private static void tick(Minecraft mc) {
        AutoMaceConfig c = AutoMaceConfig.get();
        while (toggleKey.consumeClick()) { c.enabled = !c.enabled; AutoMaceConfig.save(); }
        while (hudKey.consumeClick()) { c.hud = !c.hud; AutoMaceConfig.save(); }
        while (settingsKey.consumeClick()) {
            if (mc.gui.screen() == null) mc.gui.setScreen(AutoMaceConfig.screen(null));
        }
        target = null;
        if (!c.enabled) { status = "Disabled"; return; }
        LocalPlayer player = mc.player;
        if (player == null || mc.level == null || mc.gameMode == null || !player.isAlive()) { status = "No world"; return; }
        if (mc.gui.screen() != null) { status = "Paused in screen"; return; }
        if (c.selection.equals("clear")) { status = "No selection"; return; }
        double maxDistance = c.range * c.range;
        double nearest = maxDistance;
        for (Entity entity : mc.level.getEntities(player, player.getBoundingBox().inflate(c.range),
                e -> e instanceof LivingEntity && e.isAlive() && !e.isSpectator() && selected(e, c.selection))) {
            double distance = player.distanceToSqr(entity);
            if (distance <= nearest) { nearest = distance; target = (LivingEntity) entity; }
        }
        if (target == null) { status = "Searching"; return; }
        if (player.onGround()) { status = "Waiting to become airborne"; return; }
        if (c.aim) {
            Vec3 aim = target.getBoundingBox().getCenter();
            if (c.tracking) aim = aim.add(target.getDeltaMovement().scale(2.0));
            Vec3 offset = aim.subtract(player.getEyePosition());
            double horizontal = Math.sqrt(offset.x * offset.x + offset.z * offset.z);
            player.setYRot((float) (Math.toDegrees(Math.atan2(offset.z, offset.x)) - 90.0));
            player.setXRot((float) -Math.toDegrees(Math.atan2(offset.y, horizontal)));
        }
        if (!c.attack) { status = "Tracking; attack off"; return; }
        if (!player.getItemInHand(InteractionHand.MAIN_HAND).is(Items.MACE)) { status = "Hold a mace"; return; }
        if (!MaceItem.canSmashAttack(player)) { status = "Waiting for smash fall"; return; }
        if (!player.isWithinEntityInteractionRange(target, 0.0)) { status = "Out of reach"; return; }
        if (!player.hasLineOfSight(target)) { status = "No line of sight"; return; }
        if (!(mc.hitResult instanceof EntityHitResult hit) || hit.getEntity() != target) { status = "Waiting for crosshair"; return; }
        if (player.getAttackStrengthScale(0.5f) < 1.0f) { status = "Attack cooling down"; return; }
        mc.gameMode.attack(player, target);
        status = "Smash attempted";
    }
}