daryk454

Create a minecraft mod for Minecraft Java Verison 26.2 that makes it so it opens a little menu when you press right-shift and in the menu you have to enter a code and the code is (2027) and once you enter that code it opens a settings menu with 4 modules the first module is 'Stun Slam" which when im holding any type of axe and i hit a entity blocking with a shield and once i break it it swaps to the mace to perform a stun slam and the 2nd module is "Breach Swap" which makes it so when im holding a weapon and a attack a entity it swaps to a breach mace to perform a breach swap for extra damage and it swaps back to the weapon i was holding and the 3nd module is "Exclusive Mace Mode" which has 3 modes the first one is "Breach Mode" which makes it so all modules perfer maces with the breach enchant and the next mode is "Density Mode" which makes it so all modules perfer maces with density and the next mode is "Hybrid Mode" which perfers both Breach and Density depending on the height ur falling from so if you fall from 3 blocks or lower it uses a breach mace but it you fall from above 3 blocks it uses a density mace and the final module is "Auto Mace Swap" it makes it so if ur using any weapon it swaps to the mace for extra damage (it swaps to the mace depending on if ur using hybrid mode, density mode and breach mode)

Kodari AI
KodariSep 20 at 9:23 pm 14
MaceCombatSuite
Creates a right-shift settings menu requiring code 2027, unlocking four combat modules. Stun Slam swaps to mace after shield break for stun. Breach Swap uses breach mace then returns weapon. Exclusive Mace Mode offers Breach, Density, or Hybrid selection based on fall height. Auto Mace Swap automatically switches to optimal mace for bonus damage.

Plan:

  1. Create the Fabric 26.2 Gradle/mod metadata.

  2. Add the client keybind, code-entry screen, settings screen, and four module controls.

  3. Add mace selection and attack-time swapping logic, including Breach/Density/Hybrid mode selection.

  4. Wire the client mixin and resource files.

  1. Created a Fabric 26.2 client mod with Java 25 and Fabric API configuration.

  2. Added a Right Shift keybind that opens a code menu requiring 2027.

  3. Added settings for:

    • Stun Slam

    • Breach Swap

    • Exclusive Mace Mode

    • Auto Mace Swap

  4. Implemented Breach, Density, and Hybrid mace selection based on enchantments and fall distance.

  5. Added attack-time mace swapping with hotbar restoration after the attack.

daryk454

can you also add another module called 'Shield Break" which makes it so when a player is blocking or if a player starts blocking with a shield it swaps to the axe and breaks their shjield and swaps back to the weapon i was holding. and can you also fix the stun slam it doesnt seem to work properly made a contradiction of modules and fix them if there is

Kodari AI
KodariSep 20 at 11:24 pm 5
  1. Add Shield Break with reliable shield-detection, axe swap, attack, and weapon restoration.

  2. Resolve the Stun Slam/Breach/Auto Mace conflicts so each attack chooses one action and restores the original slot safely.

  1. Added the Shield Break module with a settings toggle.

    • Detects a blocking shield.

    • Swaps to the first axe in the hotbar.

    • Performs the axe attack so vanilla shield-disable behavior activates.

    • Restores the original weapon afterward.

  2. Fixed Stun Slam.

    • It now waits for the shield to actually stop blocking before switching to the mace.

    • Performs the mace attack through the normal client attack path.

    • Restores the original weapon after the slam.

    • Prevents duplicate attacks while waiting.

  3. Resolved module conflicts.

    • Shield-related attacks take priority over Breach Swap and Auto Mace Swap.

    • Breach Swap takes priority over Auto Mace Swap for normal weapon attacks.

    • Manual hotbar changes are not overwritten during restoration.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
9 560
src/client/java/com/example/macemodules/MaceModulesClient.java
package com.example.macemodules;

import com.mojang.blaze3d.platform.InputConstants;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keymapping.v1.KeyMappingHelper;
import net.fabricmc.fabric.api.event.client.player.ClientPreAttackCallback;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.AxeItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.phys.EntityHitResult;

public final class MaceModulesClient implements ClientModInitializer {
    public static final String MOD_ID = "macemodules";
    public static final MaceModuleSettings SETTINGS = new MaceModuleSettings();

    private static final KeyMapping OPEN_MENU = KeyMappingHelper.registerKeyMapping(new KeyMapping(
        "key.macemodules.open_menu",
        InputConstants.Type.KEYSYM,
        InputConstants.KEY_RSHIFT,
        KeyMapping.Category.MISC
    ));

    private static int restoreSlot = -1;
    private static int swappedSlot = -1;
    private static LivingEntity pendingStunTarget;
    private static int pendingStunOriginalSlot = -1;
    private static int pendingStunWaitTicks;

    @Override
    public void onInitializeClient() {
        ClientPreAttackCallback.EVENT.register(MaceModulesClient::beforeAttack);
        ClientTickEvents.END_CLIENT_TICK.register(MaceModulesClient::endClientTick);
    }

    private static boolean beforeAttack(Minecraft client, LocalPlayer player, int clickCount) {
        if (client.gui.screen() != null || client.hitResult == null || client.gameMode == null) {
            return false;
        }

        Entity target = getEntityTarget(client);
        if (!(target instanceof LivingEntity livingTarget)) {
            return false;
        }

        if (pendingStunTarget == livingTarget) {
            return true;
        }

        ItemStack heldItem = player.getInventory().getSelectedItem();
        boolean shieldTarget = isShieldTarget(livingTarget);

        if (shieldTarget) {
            if (SETTINGS.shieldBreakEnabled()) {
                int axeSlot = findAxeSlot(player);
                if (axeSlot >= 0) {
                    int originalSlot = player.getInventory().getSelectedSlot();
                    swapToHotbarSlot(player, axeSlot);
                    if (SETTINGS.stunSlamEnabled()) {
                        queueStunSlam(livingTarget, originalSlot);
                    }
                    return false;
                }
            }

            if (SETTINGS.stunSlamEnabled() && heldItem.getItem() instanceof AxeItem) {
                queueStunSlam(livingTarget, player.getInventory().getSelectedSlot());
                return false;
            }

            return false;
        }

        if (isWeapon(heldItem)) {
            if (SETTINGS.breachSwapEnabled()) {
                return swapToConfiguredMace(player);
            }
            if (SETTINGS.autoMaceSwapEnabled()) {
                return swapToConfiguredMace(player);
            }
        }

        return false;
    }

    private static Entity getEntityTarget(Minecraft client) {
        if (client.hitResult instanceof EntityHitResult entityHitResult) {
            return entityHitResult.getEntity();
        }
        return null;
    }

    private static boolean isShieldTarget(LivingEntity target) {
        ItemStack blockingItem = target.getItemBlockingWith();
        return target.isBlocking() && blockingItem != null && blockingItem.getItem() == Items.SHIELD;
    }

    private static boolean isWeapon(ItemStack stack) {
        return stack.getItem() instanceof AxeItem || stack.has(net.minecraft.core.component.DataComponents.WEAPON);
    }

    private static int findAxeSlot(LocalPlayer player) {
        for (int slot = 0; slot < 9; slot++) {
            if (player.getInventory().getItem(slot).getItem() instanceof AxeItem) {
                return slot;
            }
        }
        return -1;
    }

    private static boolean swapToConfiguredMace(LocalPlayer player) {
        int maceSlot = MaceSelection.findMaceSlot(player, SETTINGS.mode());
        if (maceSlot < 0 || player.getInventory().getSelectedSlot() == maceSlot) {
            return false;
        }

        swapToHotbarSlot(player, maceSlot);
        return false;
    }

    private static void swapToHotbarSlot(LocalPlayer player, int slot) {
        int currentSlot = player.getInventory().getSelectedSlot();
        if (currentSlot == slot) {
            return;
        }

        if (restoreSlot < 0) {
            restoreSlot = currentSlot;
        }
        swappedSlot = slot;
        player.getInventory().setSelectedSlot(slot);
    }

    private static void queueStunSlam(LivingEntity target, int originalSlot) {
        if (pendingStunTarget == null) {
            pendingStunTarget = target;
            pendingStunOriginalSlot = originalSlot;
            pendingStunWaitTicks = 0;
        }
    }

    private static void endClientTick(Minecraft client) {
        while (OPEN_MENU.consumeClick()) {
            if (client.gui.screen() == null) {
                client.gui.setScreen(new CodeScreen());
            }
        }

        if (client.player == null) {
            clearCombatState();
            return;
        }

        if (pendingStunTarget != null) {
            processPendingStun(client, client.player);
            return;
        }

        restoreSwappedSlot(client.player);
    }

    private static void processPendingStun(Minecraft client, LocalPlayer player) {
        if (!isShieldTarget(pendingStunTarget)) {
            if (restoreSlot >= 0 && player.getInventory().getSelectedSlot() != swappedSlot) {
                clearCombatState();
                return;
            }

            int maceSlot = MaceSelection.findMaceSlot(player, SETTINGS.mode());
            if (maceSlot < 0) {
                restoreSwappedSlot(player);
                clearStunState();
                return;
            }

            if (restoreSlot < 0) {
                restoreSlot = pendingStunOriginalSlot;
            }
            swappedSlot = maceSlot;
            player.getInventory().setSelectedSlot(maceSlot);
            if (client.gameMode != null) {
                client.gameMode.attack(player, pendingStunTarget);
            }
            clearStunState();
            return;
        }

        pendingStunWaitTicks++;
        if (pendingStunWaitTicks >= 10) {
            restoreSwappedSlot(player);
            clearStunState();
        }
    }

    private static void restoreSwappedSlot(LocalPlayer player) {