Fire Ice King

🛠️ Available Versions Fabric 1.21.11 Fabric 1.26.2

📦 Requirements Fabric API Cloth Config API

⚡ Features Stun Slam — Chain different weapons together, such as Axe → Mace.

Attribute Swap — Use the attributes of another item, such as activating Spear Lunge through a trigger item. 3 Configurable Trigger Slots Fully customizable item and hotbar slot setup.

Also add a configuration screen

Kodari AI
KodariNov 15 at 3:20 am 1

This project targets Fabric 26.2, so it can build the mod for 26.2 only—not both versions in one project. “Fabric 1.26.2” isn’t a supported version; Kodari supports Fabric 26.2 and 1.21.11 as separate projects. Which version should I target?

Fire Ice King

26.2 only

Kodari AI
KodariNov 15 at 3:34 am 4
  1. Create a Fabric 26.2 mod scaffold and register three configurable weapon-trigger mappings.

  2. Implement server-side item substitution for configured hotbar slots, with matching client interaction handling.

  3. Add an in-game settings screen for general enablement and each trigger, plus packaged YACL/ModMenu dependencies.

Implemented the Fabric 26.2 client mod with three configurable trigger mappings. Each mapping can match trigger/action item IDs and hotbar slots, then route entity attacks or item uses through the action item. The original selection is restored afterward; sustained item use keeps the action item selected until use ends.

The config screen is available through Mod Menu, with General and Trigger 1–3 tabs. Trigger 1 defaults to slot 0 iron axe → slot 1 mace; Trigger 2 has a disabled iron sword → spear preset; Trigger 3 is blank. Settings save to config/weapontriggers.json.

The screen uses YACL with Mod Menu rather than Cloth Config, the supported settings-screen libraries for this project. The mod is client-side and uses vanilla hotbar updates.

Fire Ice King

Is it done?

Kodari AI
KodariNov 15 at 3:37 am 1

Yes—the Fabric 26.2 mod and its configuration screen are in the project. Compile it using Compile in the top bar, then download the jar when the build succeeds.

Kodari can make mistakes. Review important code before using.
Files
src
auto_attributeswap_stunslam-1.0.0.jar
build.gradle
gradle.properties
gson-0.1.7.jar
manifest.kod
settings.gradle
Code
11 434
src/client/java/com/kodari/weapontriggers/client/WeaponTriggersClient.java
package com.kodari.weapontriggers.client;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
import net.fabricmc.fabric.api.event.player.UseItemCallback;
import net.minecraft.client.Minecraft;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
import net.minecraft.world.InteractionHand;
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;

public final class WeaponTriggersClient implements ClientModInitializer {
    private static Player pendingPlayer;
    private static int pendingOriginalSlot = -1;
    private static int pendingActionSlot = -1;
    private static boolean waitForItemUseToFinish;

    @Override
    public void onInitializeClient() {
        WeaponTriggersConfig.load();

        UseItemCallback.EVENT.register((player, level, hand) -> {
            if (hand == InteractionHand.MAIN_HAND) {
                applyTrigger(player, false);
            }
            return InteractionResult.PASS;
        });

        AttackEntityCallback.EVENT.register((player, level, hand, entity, hitResult) -> {
            if (hand == InteractionHand.MAIN_HAND) {
                applyTrigger(player, true);
            }
            return InteractionResult.PASS;
        });

        ClientTickEvents.END_CLIENT_TICK.register(WeaponTriggersClient::restorePendingSlot);
    }

    private static void applyTrigger(Player player, boolean synchronizeBeforeAction) {
        Minecraft client = Minecraft.getInstance();
        if (client.player != player || pendingOriginalSlot >= 0 || !WeaponTriggersConfig.get().enabled) {
            return;
        }

        var connection = client.getConnection();
        if (connection == null) {
            return;
        }

        Inventory inventory = player.getInventory();
        int selectedSlot = inventory.getSelectedSlot();
        for (WeaponTriggersConfig.TriggerConfig trigger : WeaponTriggersConfig.get().triggers()) {
            if (trigger == null || !trigger.enabled
                    || trigger.triggerSlot < 0 || trigger.triggerSlot > 8
                    || trigger.actionSlot < 0 || trigger.actionSlot > 8
                    || selectedSlot != trigger.triggerSlot
                    || trigger.actionSlot == selectedSlot) {
                continue;
            }

            ItemStack triggerStack = inventory.getItem(trigger.triggerSlot);
            ItemStack actionStack = inventory.getItem(trigger.actionSlot);
            if (!matches(triggerStack, trigger.triggerItem) || !matches(actionStack, trigger.actionItem)) {
                continue;
            }

            inventory.setSelectedSlot(trigger.actionSlot);
            pendingPlayer = player;
            pendingOriginalSlot = selectedSlot;
            pendingActionSlot = trigger.actionSlot;
            waitForItemUseToFinish = !synchronizeBeforeAction;
            if (synchronizeBeforeAction) {
                connection.send(new ServerboundSetCarriedItemPacket(trigger.actionSlot));
            }
            return;
        }
    }

    private static boolean matches(ItemStack stack, String configuredId) {
        if (stack.isEmpty()) {
            return false;
        }

        String expectedId = configuredId == null ? "" : configuredId.trim();
        return expectedId.isEmpty() || BuiltInRegistries.ITEM.getKey(stack.getItem()).toString().equals(expectedId);
    }

    private static void restorePendingSlot(Minecraft client) {
        if (pendingOriginalSlot < 0) {
            return;
        }

        var connection = client.getConnection();
        if (pendingPlayer == null || client.player != pendingPlayer || connection == null) {
            clearPending();
            return;
        }

        if (waitForItemUseToFinish && pendingPlayer.isUsingItem()) {
            return;
        }

        Inventory inventory = pendingPlayer.getInventory();
        int slotToSynchronize = inventory.getSelectedSlot();
        if (slotToSynchronize == pendingActionSlot) {
            slotToSynchronize = pendingOriginalSlot;
            inventory.setSelectedSlot(slotToSynchronize);
        }

        connection.send(new ServerboundSetCarriedItemPacket(slotToSynchronize));
        clearPending();
    }

    private static void clearPending() {
        pendingPlayer = null;
        pendingOriginalSlot = -1;
        pendingActionSlot = -1;
        waitForItemUseToFinish = false;
    }
}