Jzpm

Create a Minecraft Java Edition Fabric 1.21.11 client-side PvP mod called Stun Slam.

The mod should automate the Axe → Mace Stun Slam technique.

Core behavior:

  • Detect when the player is targeting another player who is actively using a shield.
  • Scan the player's hotbar for a usable Axe and Mace.
  • Remember the hotbar slot containing the Axe and the slot containing the Mace.
  • Automatically switch to the Axe slot.
  • Perform an Axe attack against the shielded target to trigger the normal vanilla shield-disable mechanic.
  • Immediately after the Axe hit, switch to the Mace slot.
  • Perform the Mace attack against the same target within the valid Stun Slam timing window.
  • The Axe → Mace sequence must happen extremely quickly and be synchronized with Minecraft's tick/attack timing.
  • Do not switch to random slots; only use the detected Axe and Mace slots.
  • If either an Axe or Mace is missing from the hotbar, do nothing.
  • If the target stops using their shield, changes target, dies, or moves out of valid attack range, cancel the sequence.
  • Only trigger the sequence when a valid shielded player is being targeted.
  • Return to the player's original hotbar slot after the sequence finishes, if possible.

Detection:

  • Detect the target's actual shield/blocking state rather than simply checking whether they own a shield.
  • Detect both main-hand and off-hand shields where applicable.
  • Make the detection responsive enough for PvP.
  • Do not attack through walls or outside normal Minecraft attack range.

Timing:

  • Add a configurable Stun Slam timing window.
  • Default to a very short window appropriate for same-tick PvP mechanics.
  • Synchronize the Axe hit, slot switch, and Mace hit as precisely as possible with client/server ticks.
  • Avoid sending unnecessary or repeated attack packets.

Safety and behavior:

  • Do not modify the vanilla Axe or Mace items.
Kodari AI
KodariSep 25 at 9:05 am 2
StunSlam
Client-side Fabric mod automating the Axe-to-Mace Stun Slam PvP technique. Detects shielded targets, scans hotbar for Axe and Mace slots, then rapidly performs an Axe attack to disable the shield followed by a synchronized Mace strike within a configurable timing window. Cancels safely on target changes, range loss, or shield drop, and restores the original hotbar slot after execution.
  1. Register the client tick handler and read a small config file for the mace timing window.

  2. Detect a shield-blocking player in the vanilla crosshair target and resolve usable hotbar axe/mace slots.

  3. Run the ordered attacks with slot synchronization, target/range checks, and slot restoration.

Created Stun Slam as a Fabric 1.21.11 client-only mod. It targets only the vanilla crosshair’s actively blocking player, checks reach with the selected weapon, then uses the first Axe and Mace found in the hotbar. Each attack synchronizes the selected slot before sending; the original slot is restored afterward.

The generated config/stun_slam.properties supports timing_window_ticks from 0–5. It defaults to 0, sending both attacks in the same client tick. The mod does not modify vanilla items.

Jzpm

make it so that its not perfect and not the same tick

Kodari AI
KodariSep 25 at 9:25 am 1
  1. Replace the same-tick path with a randomized delay of at least one tick.

  2. Set the default delay range to 1–3 ticks; clamp configured values so zero can’t re-enable same-tick attacks.

Axe-to-Mace timing now varies randomly from 1 to 3 ticks by default, so the attacks never happen in the same tick. timing_window_ticks sets the maximum delay (1–5); old configs set to 0 now use the 3-tick default.

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

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.MinecraftClient;
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.item.MaceItem;
import net.minecraft.util.hit.EntityHitResult;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Properties;
import java.util.concurrent.ThreadLocalRandom;

public final class StunSlamClient implements ClientModInitializer {
    private static final Path CONFIG_PATH = Path.of("config", "stun_slam.properties");
    private static final int MAX_TIMING_WINDOW_TICKS = 5;

    private static int timingWindowTicks;
    private static PlayerEntity lockedTarget;
    private static PendingSequence pendingSequence;

    @Override
    public void onInitializeClient() {
        timingWindowTicks = loadTimingWindowTicks();
        ClientTickEvents.END_CLIENT_TICK.register(StunSlamClient::onEndClientTick);
    }

    private static void onEndClientTick(MinecraftClient client) {
        if (pendingSequence != null) {
            PendingSequence sequence = pendingSequence;
            if (client.player == null || client.world == null || client.interactionManager == null
                    || client.player != sequence.player
                    || !isCurrentTargetValid(client, sequence.player, sequence.target)) {
                completePendingSequence(client, sequence, false);
                return;
            }

            if (sequence.ticksUntilMace > 0) {
                sequence.ticksUntilMace--;
                if (sequence.ticksUntilMace > 0) {
                    return;
                }
            }

            completePendingSequence(client, sequence, true);
            return;
        }

        PlayerEntity player = client.player;
        if (player == null || client.world == null || client.interactionManager == null) {
            lockedTarget = null;
            return;
        }

        PlayerEntity target = null;
        if (client.crosshairTarget instanceof EntityHitResult hit
                && hit.getEntity() instanceof PlayerEntity hitPlayer) {
            target = hitPlayer;
        }

        if (lockedTarget != null) {
            if (lockedTarget == target && isShieldBlocking(target)) {
                return;
            }
            lockedTarget = null;
        }

        if (target == null || target == player || !isShieldBlocking(target)) {
            return;
        }

        int[] slots = findAxeAndMaceSlots(player.getInventory());
        if (slots[0] < 0 || slots[1] < 0) {
            return;
        }

        PlayerInventory inventory = player.getInventory();
        int originalSlot = inventory.getSelectedSlot();
        inventory.setSelectedSlot(slots[0]);
        if (!isCurrentTargetValid(client, player, target)) {
            inventory.setSelectedSlot(originalSlot);
            return;
        }

        client.interactionManager.attackEntity(player, target);
        lockedTarget = target;
        inventory.setSelectedSlot(slots[1]);

        int delayTicks = ThreadLocalRandom.current().nextInt(1, timingWindowTicks + 1);
        pendingSequence = new PendingSequence(player, target, originalSlot, delayTicks);
    }

    private static boolean isShieldBlocking(PlayerEntity target) {
        return target != null
                && target.isBlocking()
                && target.getActiveItem().isOf(Items.SHIELD);
    }

    private static boolean isCurrentTargetValid(MinecraftClient client, PlayerEntity player, PlayerEntity target) {
        return client.player == player
                && client.world != null
                && target.isAlive()
                && target.getEntityWorld() == player.getEntityWorld()
                && client.crosshairTarget instanceof EntityHitResult hit
                && hit.getEntity() == target
                && player.canAttackEntityIn(target.getBoundingBox(), 0.0);
    }

    private static int[] findAxeAndMaceSlots(PlayerInventory inventory) {
        int axeSlot = -1;
        int maceSlot = -1;

        for (int slot = 0; slot < PlayerInventory.getHotbarSize(); slot++) {
            ItemStack stack = inventory.getStack(slot);
            if (stack.isEmpty()) {
                continue;
            }

            if (axeSlot < 0 && stack.getItem() instanceof AxeItem) {
                axeSlot = slot;
            }
            if (maceSlot < 0 && stack.getItem() instanceof MaceItem) {
                maceSlot = slot;
            }
            if (axeSlot >= 0 && maceSlot >= 0) {
                break;
            }
        }

        return new int[]{axeSlot, maceSlot};
    }

    private static void completePendingSequence(MinecraftClient client, PendingSequence sequence, boolean attackMace) {
        if (pendingSequence != sequence) {
            return;
        }

        if (attackMace && client.player == sequence.player && client.interactionManager != null
                && isCurrentTargetValid(client, sequence.player, sequence.target)) {
            client.interactionManager.attackEntity(sequence.player, sequence.target);
        }

        if (client.player == sequence.player) {
            sequence.player.getInventory().setSelectedSlot(sequence.originalSlot);
        }
        pendingSequence = null;
    }

    private static int loadTimingWindowTicks() {
        Properties properties = new Properties();
        try {
            Files.createDirectories(CONFIG_PATH.getParent());
            if (Files.exists(CONFIG_PATH)) {
                try (InputStream input = Files.newInputStream(CONFIG_PATH)) {
                    properties.load(input);
                }
            } else {
                properties.setProperty("timing_window_ticks", "3");
                try (OutputStream output = Files.newOutputStream(CONFIG_PATH)) {
                    properties.store(output, "Maximum randomized ticks between axe and mace attacks; minimum is 1, maximum is 5");
                }
            }
        } catch (IOException ignored) {
            return 0;
        }

        try {
            int configuredTicks = Integer.parseInt(properties.getProperty("timing_window_ticks", "3").trim());
            return configuredTicks <= 0 ? 3 : Math.max(1, Math.min(MAX_TIMING_WINDOW_TICKS, configuredTicks));
        } catch (NumberFormatException ignored) {
            return 3;
        }
    }

    private static final class PendingSequence {
        private final PlayerEntity player;
        private final PlayerEntity target;
        private final int originalSlot;
        private int ticksUntilMace;

        private PendingSequence(PlayerEntity player, PlayerEntity target, int originalSlot, int ticksUntilMace) {
            this.player = player;
            this.target = target;
            this.originalSlot = originalSlot;
            this.ticksUntilMace = ticksUntilMace;
        }
    }
}