William Lin

make it so every time the player hits a shielding player with a mace, the original hit won't register, automatically check if there is a axe in their hotbar, stun their sheild with it, switch back to the mace, and hit with the mace, all in one tick

Kodari AI
KodariSep 26 at 3:41 am 3
MaceShieldBreaker
Automatically detects when a player attacks a shielding opponent with a mace. On hit detection, the plugin cancels the original mace strike, scans the attacker's hotbar for an axe, equips it, disables the target's shield via axe stun mechanic, switches back to the mace, and delivers the mace hit — all within a single tick. Provides seamless shield-breaking combat enhancement for Minecraft Fabric servers.
  1. Intercept eligible mace attacks against an actively shielding target.

  2. Find a hotbar axe, cancel the original hit, then run the axe shield-break and mace hit synchronously.

  3. Add the 26.2 mod entrypoint and mixin configuration.

Created the Fabric 26.2 mod. When a player attacks a shielding player with a mace and has an axe in their hotbar, it cancels the original hit and performs the axe shield-disable attack, switches back, and attacks with the mace in the same tick. Without a hotbar axe, vanilla behavior is unchanged.

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

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.ShieldItem;

public class MaceShieldCombo implements ModInitializer {
	private static final ThreadLocal<Boolean> REPLAYING_ATTACK = ThreadLocal.withInitial(() -> false);

	@Override
	public void onInitialize() {
		AttackEntityCallback.EVENT.register((player, level, hand, entity, hitResult) -> {
			if (REPLAYING_ATTACK.get() || !(entity instanceof Player target)) {
				return InteractionResult.PASS;
			}

			ItemStack blockingStack = target.getItemBlockingWith();
			if (blockingStack == null
					|| !(blockingStack.getItem() instanceof ShieldItem)
					|| player.getMainHandItem().getItem() != Items.MACE) {
				return InteractionResult.PASS;
			}

			Inventory inventory = player.getInventory();
			int originalSlot = inventory.getSelectedSlot();
			int axeSlot = findAxeSlot(inventory);
			if (axeSlot < 0) {
				return InteractionResult.PASS;
			}

			if (level.isClientSide()) {
				return InteractionResult.SUCCESS;
			}

			REPLAYING_ATTACK.set(true);
			try {
				inventory.setSelectedSlot(axeSlot);
				player.attack(target);
				inventory.setSelectedSlot(originalSlot);
				target.invulnerableTime = 0;
				player.attack(target);
			} finally {
				inventory.setSelectedSlot(originalSlot);
				REPLAYING_ATTACK.remove();
			}

			return InteractionResult.FAIL;
		});
	}

	private static int findAxeSlot(Inventory inventory) {
		for (int slot = 0; slot < 9; slot++) {
			if (inventory.getItem(slot).is(ItemTags.AXES)) {
				return slot;
			}
		}
		return -1;
	}
}