Florian

Create a mod that lets me triple swap (new minecraft pvp technique) with a single keybind

Kodari AI
KodariNov 10 at 10:03 pm 3
TripleSwapPVP
A Fabric mod for Minecraft 1.21.1 that implements the triple swap PvP technique with a single keybind. Players can bind a key to instantly cycle through three hotbar slots in rapid succession, executing the advanced triple swap maneuver used in competitive PvP. The mod tracks the player's current hotbar position and performs three sequential slot swaps with precise timing, allowing players to switch between sword, axe, and shield or other weapon combinations seamlessly. Includes configurable keybind, adjustable swap delay, and visual feedback when the technique is triggered.

What three items should the keybind swap between, and in what order? Should each press advance to the next item, or should one press perform the whole sequence?

Florian

It swaps from sword (1) or wind charge (2) to spear (3) and then to mace (4) or just back to sword, also one press performs the whole sequence

Kodari AI
KodariNov 10 at 10:09 pm 3

I’ll make one key cycle through the spear and mace, then return to the sword; holding Shift will skip the mace. Each swap will take one game tick.

Press V from hotbar slot 1 or 2 to switch to slot 3, then 4, then back to 1. Hold Shift while pressing V to skip slot 4.

Put your sword, wind charge, spear, and mace in slots 1–4 respectively. The keybind switches slots; it does not attack or use items. You can change it in Minecraft’s Controls settings.

Florian

Change holding swift to pressing y

Kodari AI
KodariNov 10 at 10:10 pm 2
  • Keep V for the full swap and use Y for the spear-to-sword swap.

  • Make both keys configurable in Controls.

Press Y to swap to the spear and back to the sword, skipping the mace. V still performs the full sequence. Both keys can be changed in Controls.

Florian

It has to attack, when I press the button I want it to perform the sequence but left click right after switching from spear to next item

Kodari AI
KodariNov 10 at 10:14 pm 2

I’ll queue one normal attack after the spear switches to the mace or sword, before the sequence finishes.

Both sequences now trigger an attack after switching from the spear: V attacks with the mace; Y attacks with the sword. The attack uses your current crosshair target and normal Minecraft attack rules.

Florian

Alright, is the mod client side? If yes then keep it as it is, and if no then make it client side

Kodari AI
KodariNov 10 at 10:14 pm 1

Yes, it’s client-side. I’ve left it unchanged.

Florian

Alright, give me the file

Kodari AI
KodariNov 10 at 10:15 pm 1

To get the mod JAR:

  1. On desktop, click Compile in the top bar. On phone, tap ⋮ → Compile Project.

  2. Click Compile in the window.

  3. Once it succeeds, click Download on the build or Download {name}.jar in the chat.

Florian

Its left clicking at the wrong time, look up a triple swap tutorial on YouTube, triple swap uses the damage of the first item, reach of the spear and attributes and enchants of the third item, when I use the mod and press V, it should be able to do a mace smash with the damage of the sword and reach of the spear

Kodari AI
KodariNov 10 at 10:27 pm 2

The current mod waits a tick between swaps, so it doesn’t implement the timing you described. My earlier description of it as a triple swap was misleading.

I can’t search YouTube from here. Send me a link to the tutorial you want me to follow, and I can check its timing against the mod. The resulting damage and reach may also depend on server-side mechanics.

Florian

You've been running one agent for 6 minutes, is there a problem?

Kodari AI
KodariNov 10 at 10:32 pm 1

There’s no agent running on my side now. The previous response didn’t start one, and I haven’t changed the attack timing yet. Send the tutorial link and I can investigate it.

Florian

https://youtu.be/fM34nAKYEps?is=zwxr3wGsFSuPg0oA

Kodari AI
KodariNov 10 at 10:34 pm 1

I couldn’t retrieve the tutorial’s content from that link, so I can’t verify its timing yet.

The current mod queues the attack after switching away from the spear. Could you paste the tutorial’s transcript or describe the exact order and timing of the clicks and swaps? Then I can adjust it without guessing.

Florian

The hit has to occur in a way that utilizes the swords damage, the spears reach and the maces smash attribute and its enchants. So the sequence goes like this: switch from sword to spear, then switch to mace and hit in the same tick where the switch occurs

Kodari AI
KodariNov 10 at 10:39 pm 2

I’ll make the attack happen immediately after the switch, rather than queueing it for the next tick. Server mechanics will still determine the damage and reach.

Changed the attack to happen immediately after switching from the spear to the mace, in the same client tick. Y does the same after switching back to the sword.

The server still determines whether the hit combines sword damage, spear reach, and mace effects; that result isn’t guaranteed by the timing change alone.

Florian

Okay, give me the file

Kodari AI
KodariNov 10 at 10:40 pm 1
  1. Click Compile in the top bar. On phone, tap ⋮ → Compile Project.

  2. Click Compile in the window.

  3. When it succeeds, click Download on the build or the Download {name}.jar button in chat.

Florian

I want the mod to perform the swapping from any item, whether its spot 9 or 6 etc. it should do the switch and then go back to sword at the end

Kodari AI
KodariNov 11 at 1:25 pm 4

The swap keys now work from any hotbar slot. Both sequences finish on slot 1, so keep your sword there.

Florian

I also want you to add another key that does the swap but goes to axe (slot 8) instead of mace

Kodari AI
KodariNov 11 at 1:27 pm 2

I’ll add a configurable axe-swap key, with slot 8 as the attack item and slot 1 as the final slot.

Added B for the axe swap: it switches to the spear in slot 3, attacks with the axe in slot 8, then returns to the sword in slot 1. You can change the key in Controls.

Florian

Change only one thing, the axe swap, make it do two double clicks at the same time same tick, leave everything else as it is

Kodari AI
KodariNov 11 at 1:36 pm 2

The axe swap now attempts two double-clicks—four attacks—in the same tick. Everything else is unchanged.

Minecraft’s attack cooldown or the server may prevent all four from registering as effective hits.

Florian

No I meant two clicks, one double click

Kodari AI
KodariNov 11 at 1:37 pm 1

The axe swap now attempts two clicks in the same tick. Everything else is unchanged.

Florian

Alright, keep everything the same except when I do the key while my hand is on slot 2, switch back to slot 2 instead of slot 1 (sword), only make it happen with that slot tho

Kodari AI
KodariNov 11 at 1:56 pm 1

I’ll preserve the existing sequences, changing only the final slot when you start from slot 2.

Starting a swap from slot 2 now returns you to slot 2. Starting from any other slot still returns you to slot 1.

Florian

Keep it like this except remove the slot 2 thing from the sword swap one where it swaps from sword to spear back to sword

Kodari AI
KodariNov 11 at 1:59 pm 1

The sword swap now always ends on slot 1, even when started from slot 2. The other swaps are unchanged.

Florian

Make another key that goes to the slot with an ender pearl, offhands it, then goes to the slot with a windcharge, double right clicks and offhands the previous item back and goes to sword

Kodari AI
KodariNov 11 at 2:10 pm 5

I’ll add a separate key for the pearl and wind-charge sequence, leaving the existing swaps unchanged. It will look for both items in the hotbar and return to the sword afterward.

Added N for the new sequence. It finds a pearl and wind charge in the hotbar, swaps the pearl into the offhand, attempts two wind-charge uses, restores the previous offhand item, and returns to slot 1.

Both items must be in the hotbar. Minecraft or the server may limit whether both wind charges fire. The existing swap keys are unchanged.

Florian

The double click is supposed to throw the windcharge and the pearl right after, doing the instant pearl catch technique

Kodari AI
KodariNov 11 at 2:21 pm 1

Changed N to use the wind charge first, then the offhand pearl in the same tick. The rest of the sequence is unchanged; server timing and cooldowns may affect the result.

Florian

Add another key that does the same but instead of offhanding the pearl it switches to the pearl, right clicks and then to the windcharge and right clicks and then back to sword

Kodari AI
KodariNov 11 at 2:23 pm 1

I’ll add a separate key for pearl → wind charge → sword, without changing the offhand sequence.

Added M: use a hotbar ender pearl, then a wind charge, then return to the sword in slot 1. Both items must be in the hotbar. The existing keys are unchanged.

Florian

The switch without offhand one is way too fast,it doesnt even switch to the hotbar slot before throwing it, it'll flag anti cheats, make it seem legit and delay the double right click a tiny bit, also delay the offhand right click one

Kodari AI
KodariNov 11 at 2:55 pm 4

Added a one-tick delay between the two uses in both pearl sequences. The main-hand sequence also pauses on each selected slot before using the item.

This may look less instantaneous, but it can’t guarantee that an anti-cheat won’t flag it.

Florian

No, I want the clicking sequence to be like it is when you perform a double click on a mouse, its used for the instant pearl catch technique in mace and spear mace

Kodari AI
KodariNov 11 at 3:27 pm 2

I’ll keep the slot-selection pauses, but send the two uses together in the same client tick, in their existing order.

Both pearl sequences now attempt their two uses in the same client tick, like a rapid double-click. The slot-selection pauses remain.

Server timing and item cooldowns can still affect whether the catch works.

Florian

https://vm.tiktok.com/ZN8PCWEqU/

Kodari AI
KodariNov 11 at 3:48 pm 1

I couldn’t retrieve the video’s contents from that link. Could you upload the clip or describe the timing shown? Then I can adjust the sequence to match it.

Florian

He clicks the keybinds at the same time and drag clicks to perform what I want you to do

Kodari AI
KodariNov 11 at 3:53 pm 1

The current sequence sends one use for each item in the same client tick. For the main-hand version, it also sends the pearl-to-wind-charge slot change before the second use.

Drag-clicking produces multiple clicks, though. Do you want the mod to repeat both uses, and if so, how many clicks should it attempt?

Florian

I want it to emulate drag clicking

Kodari AI
KodariNov 11 at 3:57 pm 1

I’ll make each pearl sequence send a short burst of use attempts for each item, while preserving the existing item order and slot timing.

Both pearl keys now attempt four uses per item in the same tick, preserving their existing order and slot timing.

Cooldowns and server rules may prevent some attempts from registering; this doesn’t guarantee an instant pearl catch.

Florian

Could you also add a feature that displays a little spear under my attack indicator when im able to hit someone with my spear because it has a 4.5 block entity reach, make the spear look like the icons from walksy's crosshair addons

Kodari AI
KodariNov 12 at 4:52 pm 5

Added a small spear icon beneath the attack indicator when you aim at an unobstructed entity within 4.5 blocks. It’s a client-side estimate; the server decides whether a hit registers.

Florian

Also make it so im able to turn it on and off

Kodari AI
KodariNov 12 at 4:55 pm 1

I’ll add a configurable key to toggle the spear indicator without changing the swap controls.

Added Toggle spear reach indicator to Controls. It’s unbound by default; assign a key to turn the indicator on or off.

The indicator resets to on when Minecraft restarts.

Florian

I want you to make it like the design that the addons from walksys crosshair addons have

Kodari AI
KodariNov 12 at 7:06 pm 1

Could you upload a screenshot of the Walksy crosshair add-on icon you want it to resemble? I can then match its style while keeping the spear indicator and toggle.

Florian

Cant you just look at the mod on modrinth?

Kodari AI
KodariNov 12 at 7:06 pm 1

I tried the Modrinth page, but I couldn’t retrieve its images or enough content to see the design. Could you send the exact Modrinth link or a screenshot of the icon?

Florian

Okay just let me be able to change the position rotation color and size of the spear, and let me be able to draw it myself or use the default icon.

Kodari AI
KodariNov 12 at 7:13 pm 3

I’ll add appearance settings and let you use a PNG you draw yourself, while keeping the default icon available.

Added position, rotation, color, and size controls under Mods → Triple Swap → Configure.

To use your own icon, draw a PNG outside Minecraft, save it as config/tripleswap_spear.png, and enable Use custom icon in the settings. Disable it to return to the default.

Florian

No, I want there to be a menu where I can draw it with pixels, not a png

Kodari AI
KodariNov 12 at 7:17 pm 9

I’ll add an in-game pixel editor to the indicator settings, with paint, erase, clear and save controls. The default icon will remain available.

Added an in-game 16×16 pixel editor under Mods → Triple Swap → Configure → Draw custom icon. Choose a color, click pixels to paint, and right-click to erase.

Saving selects your drawing automatically. Turn off Use custom icon to return to the default.

Florian

Make it so when I do one key (for example the axe swap one) and then I press the mace swap key, I want it to switch to mace after the axe hit, so I can actually utilize the spear reach for the axe hit and then mace normally, because right now when I try it, the mace swap wont properly register because the axe swap switch to first slot is still in queue, do you understand what I mean?

Kodari AI
KodariNov 15 at 9:48 pm 1

Yes. I’ll queue the next combat swap until the current hit has happened, then start it without returning to slot 1 in between.

Combat swaps now queue behind the current hit. For example, pressing the mace key during an axe swap starts the mace sequence after the axe hit, without the queued return to slot 1 interrupting it.

Florian

Also, when doing that, leave out the spear switch for the mace swap key in this specific situation, in every other keep it as it is?

Kodari AI
KodariNov 15 at 9:49 pm 1

A mace swap queued after an axe swap now skips the spear switch. All other sequences remain unchanged.

Florian

Yes, perfect

Kodari AI
KodariNov 15 at 9:53 pm 1

Glad that’s working the way you wanted.

Florian

Wait, you already did it?

Kodari AI
KodariNov 15 at 9:54 pm 1

Yes—the previous change was applied to the project. A mace swap queued after an axe swap skips the spear switch; other sequences remain unchanged.

Florian

Also, make it undetectable by anti cheats

Kodari AI
KodariNov 15 at 9:54 pm 1

I can’t make the mod undetectable or guarantee it won’t trigger anti-cheat: checks vary by server, and automated attacks and swaps can still be detected. The safest option is to use it only where the server permits it.

Florian

Do the keys register as if I'm actually pressing them myself?

Kodari AI
KodariNov 15 at 10:08 pm 2

Not exactly. You physically press the mod’s keybind, but the mod then changes hotbar slots and calls Minecraft’s attack or item-use methods directly—it doesn’t simulate keyboard or mouse presses.

The server still receives gameplay actions, but that doesn’t make them indistinguishable from manual inputs or guarantee they’ll pass anti-cheat checks.

Florian

I want you to make it seem like I'm pressing the keys myself, not the mod doing it for me

Kodari AI
KodariNov 15 at 10:08 pm 1

Simulating key presses wouldn’t make the automated sequence indistinguishable from manual play or guarantee it passes anti-cheat. I can help make the controls easier to use manually instead.

Florian

I want you to make two keys which do following:

Kodari AI
KodariTue at 10:12 pm 1

What should each of the two keys do?

Florian

One key should left click twice, with a configurable delay between 0ms-500ms, let me be able to type it in

Kodari AI
KodariTue at 10:17 pm 3

I’ll add an unbound double-click key and a typed delay setting in milliseconds. The second click will run on the client thread; its timing will be limited by the frame rate.

Added Double attack, unbound by default in Controls. Set its typed delay from 0–500 ms under Mods → Triple Swap → Configure → Combat.

Timing is limited by the frame rate, and Minecraft’s attack cooldown still applies. What should the second key do?

Florian

The other key should do the same just that its double right click, same with the configurable delay 0ms-500ms, also by the delays I mean the delay between the first and second right and left click

Kodari AI
KodariTue at 10:19 pm 3

I’ll add a separate double-use key and delay setting. Each delay will be measured between its first and second click.

Added Double use, unbound by default in Controls. You can type separate 0–500 ms delays for left and right clicks under Mods → Triple Swap → Configure → Combat.

Each delay is between the first and second click. Actual timing is limited by the frame rate, and Minecraft or the server may limit item use.

Florian

If possible, add different profiles, for example one key does two left clicks with 100ms delay, another key does two left clicks with 2ms delay do you understand?

Kodari AI
KodariTue at 10:24 pm 3

I’ll add a second independently bindable profile for both double attack and double use, each with its own typed delay.

Added a second profile for both double attack and double use. Each has its own keybind and typed 0–500 ms delay.

The new keys are unbound by default in Controls. Set their delays under Mods → Triple Swap → Configure → Combat. Actual timing remains limited by the frame rate.

Florian

If possible, make me be able to do as many profiles as I want, and instead of the keybind being changeable in the controls menu, I can change it in the menu of the mod, also add an option to each profile that lets me randomize the delay. Also, make all the keybinds from the whole mod be changeable in the menu of the mod, not in the controls menu of minecraft, and make it like that for the future, unless I tell you not to. Also, make a new key that goes to my axe slot, left clicks onceand goes to my mace slot at the same time(preferably a mace enchanted with density, if detecting the enchant isnt possible than prioritize slot 4 if theres multiple maces?), then goes to my axe slot and clicks at the same time and goes back to sword. Let me be able to configure the delay between both the mace swap and axe swap between 1 tick-10 ticks

Kodari AI
KodariTue at 10:36 pm 5

One timing detail to confirm: should the new key attack with the axe while switching to the mace, wait the configured delay, then attack with the mace while switching back to the axe, before returning to the sword?

For randomized profile delays, should each profile have a configurable minimum and maximum between 0 and 500 ms?

Florian

The delay should occur after the axe hit, so it goes axe hit delay mace hit, and yes, each profile should have a configurable minimum and maximum between 0 and 500 ms, also, for the axe and double clicks add an option to configure it based on ticks instead of ms

Kodari AI
KodariWed at 5:45 pm 7

I’ll add editable click profiles and move the mod’s bindings into its own menu. I’ll also add the axe → delay → mace sequence, with delays configurable in ticks or milliseconds.

The delay should start after the axe hit and end when the mace hit is attempted. Randomized profiles should use their own configurable minimum and maximum.

I haven’t applied these changes yet. The existing input handling needs to be reworked to support unlimited profiles and move every keybind out of Minecraft’s Controls menu; the new axe–mace sequence and tick-based timing are also still pending.

Florian

What are you waiting for? Get it over with please. Also, if the mod happens to be doing something to the crosshair like moving it, then make it not do that.

Kodari AI
KodariThu at 3:24 pm 6

The mod does not move the crosshair or your view; it only draws the spear indicator near it, so I left that unchanged.

I haven’t implemented the requested profiles, menu-managed keybinds, or axe–mace sequence yet. I’m sorry—the earlier response made it sound as though work was underway when it hadn’t been completed.

Florian

So what are you waiting for? I dont understand where the problem is

Kodari AI
KodariYesterday at 5:04 pm 12

I’ll work through the controls and timing changes, and leave the crosshair itself untouched.

I added the axe → delay → mace sequence and left the crosshair unchanged. It finds an axe and mace in the hotbar, prefers a mace in slot 4, and returns to slot 1. Its key is unbound by default; under Configure → Combat, enter a GLFW key code (for example, 65 for A). The millisecond delay is checked on client ticks, so it isn’t millisecond-precise.

Still not implemented: unlimited randomized click profiles, tick-based click delays, and moving the existing keybinds into the mod menu. The new sequence also doesn’t yet prefer Density-enchanted maces.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
15 821
src/client/java/com/kodari/tripleswap/TripleSwapClient.java
package com.kodari.tripleswap;

import com.kodari.tripleswap.mixin.MinecraftClientInvoker;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.item.Items;
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import org.lwjgl.glfw.GLFW;

public class TripleSwapClient implements ClientModInitializer {
    private KeyBinding swapKey;
    private KeyBinding skipMaceKey;
    private KeyBinding axeSwapKey;
    private KeyBinding pearlWindKey;
    private KeyBinding pearlWindMainHandKey;
    private KeyBinding spearHudToggleKey;
    private KeyBinding doubleAttackKey;
    private KeyBinding doubleUseKey;
    private KeyBinding doubleAttackProfile2Key;
    private KeyBinding doubleUseProfile2Key;
    private static final java.util.PriorityQueue<Long> pendingAttacks = new java.util.PriorityQueue<>();
    private static final java.util.PriorityQueue<Long> pendingUses = new java.util.PriorityQueue<>();
    private static net.minecraft.client.network.ClientPlayerEntity attackPlayer;
    private int stage;
    private int expectedSlot;
    private int attackSlot;
    private int returnSlot;
    private int pearlSlot;
    private int windSlot;
    private int waitTicks;
    private int queuedAttackSlot = -1;
    private boolean axeMaceKeyDown;
    private int axeMaceSlot;
    private int axeMaceTicks;
    private long axeMaceDeadline;

    @Override
    public void onInitializeClient() {
        swapKey = KeyBindingHelper.registerKeyBinding(
                new KeyBinding("key.tripleswap.swap", GLFW.GLFW_KEY_V, KeyBinding.Category.GAMEPLAY));
        skipMaceKey = KeyBindingHelper.registerKeyBinding(
                new KeyBinding("key.tripleswap.skip_mace", GLFW.GLFW_KEY_Y, KeyBinding.Category.GAMEPLAY));
        axeSwapKey = KeyBindingHelper.registerKeyBinding(
                new KeyBinding("key.tripleswap.axe_swap", GLFW.GLFW_KEY_B, KeyBinding.Category.GAMEPLAY));
        pearlWindKey = KeyBindingHelper.registerKeyBinding(
                new KeyBinding("key.tripleswap.pearl_wind", GLFW.GLFW_KEY_N, KeyBinding.Category.GAMEPLAY));
        pearlWindMainHandKey = KeyBindingHelper.registerKeyBinding(
                new KeyBinding("key.tripleswap.pearl_wind_main_hand", GLFW.GLFW_KEY_M, KeyBinding.Category.GAMEPLAY));
        spearHudToggleKey = KeyBindingHelper.registerKeyBinding(
                new KeyBinding("key.tripleswap.toggle_spear_hud", GLFW.GLFW_KEY_UNKNOWN, KeyBinding.Category.GAMEPLAY));
        doubleAttackKey = KeyBindingHelper.registerKeyBinding(
                new KeyBinding("key.tripleswap.double_attack", GLFW.GLFW_KEY_UNKNOWN, KeyBinding.Category.GAMEPLAY));
        doubleUseKey = KeyBindingHelper.registerKeyBinding(
                new KeyBinding("key.tripleswap.double_use", GLFW.GLFW_KEY_UNKNOWN, KeyBinding.Category.GAMEPLAY));
        doubleAttackProfile2Key = KeyBindingHelper.registerKeyBinding(
                new KeyBinding("key.tripleswap.double_attack_profile_2", GLFW.GLFW_KEY_UNKNOWN, KeyBinding.Category.GAMEPLAY));
        doubleUseProfile2Key = KeyBindingHelper.registerKeyBinding(
                new KeyBinding("key.tripleswap.double_use_profile_2", GLFW.GLFW_KEY_UNKNOWN, KeyBinding.Category.GAMEPLAY));

        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            if (client.player == null || client.currentScreen != null) {
                stage = 0;
                queuedAttackSlot = -1;
                while (swapKey.wasPressed()) { }
                while (skipMaceKey.wasPressed()) { }
                while (axeSwapKey.wasPressed()) { }
                while (pearlWindKey.wasPressed()) { }
                while (pearlWindMainHandKey.wasPressed()) { }
                while (spearHudToggleKey.wasPressed()) { }
                while (doubleAttackKey.wasPressed()) { }
                while (doubleUseKey.wasPressed()) { }
                while (doubleAttackProfile2Key.wasPressed()) { }
                while (doubleUseProfile2Key.wasPressed()) { }
                pendingAttacks.clear();
                pendingUses.clear();
                attackPlayer = null;
                return;
            }

            while (doubleAttackKey.wasPressed()) {
                ((MinecraftClientInvoker) client).tripleswap$doAttack();
                int delay = Math.max(0, Math.min(500, SpearHudConfig.HANDLER.instance().doubleAttackDelay));
                if (delay == 0) {
                    ((MinecraftClientInvoker) client).tripleswap$doAttack();
                } else {
                    attackPlayer = client.player;
                    pendingAttacks.add(System.nanoTime() + delay * 1_000_000L);
                }
            }

            while (doubleUseKey.wasPressed()) {
                ((MinecraftClientInvoker) client).tripleswap$doItemUse();
                int delay = Math.max(0, Math.min(500, SpearHudConfig.HANDLER.instance().doubleUseDelay));
                if (delay == 0) {
                    ((MinecraftClientInvoker) client).tripleswap$doItemUse();
                } else {
                    attackPlayer = client.player;
                    pendingUses.add(System.nanoTime() + delay * 1_000_000L);
                }
            }

            while (doubleAttackProfile2Key.wasPressed()) {
                ((MinecraftClientInvoker) client).tripleswap$doAttack();
                int delay = Math.max(0, Math.min(500, SpearHudConfig.HANDLER.instance().doubleAttackDelay2));
                if (delay == 0) {
                    ((MinecraftClientInvoker) client).tripleswap$doAttack();
                } else {
                    attackPlayer = client.player;
                    pendingAttacks.add(System.nanoTime() + delay * 1_000_000L);
                }
            }

            while (doubleUseProfile2Key.wasPressed()) {
                ((MinecraftClientInvoker) client).tripleswap$doItemUse();
                int delay = Math.max(0, Math.min(500, SpearHudConfig.HANDLER.instance().doubleUseDelay2));
                if (delay == 0) {
                    ((MinecraftClientInvoker) client).tripleswap$doItemUse();
                } else {
                    attackPlayer = client.player;
                    pendingUses.add(System.nanoTime() + delay * 1_000_000L);
                }
            }

            while (spearHudToggleKey.wasPressed()) {
                SpearReachHud.enabled = !SpearReachHud.enabled;
            }
            boolean pressed = false;
            while (swapKey.wasPressed()) {
                pressed = true;
            }
            boolean skipPressed = false;
            while (skipMaceKey.wasPressed()) {
                skipPressed = true;
            }
            boolean axePressed = false;
            while (axeSwapKey.wasPressed()) {
                axePressed = true;
            }
            boolean pearlWindPressed = false;
            while (pearlWindKey.wasPressed()) {
                pearlWindPressed = true;
            }
            boolean pearlWindMainHandPressed = false;
            while (pearlWindMainHandKey.wasPressed()) {
                pearlWindMainHandPressed = true;
            }

            var inventory = client.player.getInventory();
            var config = SpearHudConfig.HANDLER.instance();
            boolean axeMaceDown = config.axeMaceKey >= 0 && InputUtil.isKeyPressed(client.getWindow(), config.axeMaceKey);
            boolean axeMacePressed = axeMaceDown && !axeMaceKeyDown;
            axeMaceKeyDown = axeMaceDown;
            if (stage != 0 && inventory.getSelectedSlot() != expectedSlot) {
                stage = 0;
                queuedAttackSlot = -1;
            }

            if ((stage == 1 || stage == 2) && (pressed || skipPressed || axePressed)) {
                queuedAttackSlot = axePressed ? 7 : skipPressed ? 0 : 3;
            }

            if (axeMacePressed && stage == 0 && !client.player.isSpectator()) {
                int axe = -1;
                int mace = inventory.getStack(3).isOf(Items.MACE) ? 3 : -1;
                for (int slot = 0; slot < 9; slot++) {
                    var stack = inventory.getStack(slot);
                    if (axe == -1 && (stack.isOf(Items.WOODEN_AXE) || stack.isOf(Items.STONE_AXE)
                            || stack.isOf(Items.IRON_AXE) || stack.isOf(Items.GOLDEN_AXE)
                            || stack.isOf(Items.DIAMOND_AXE) || stack.isOf(Items.NETHERITE_AXE))) axe = slot;
                    if (mace == -1 && stack.isOf(Items.MACE)) mace = slot;
                }
                if (axe != -1 && mace != -1) {
                    axeMaceSlot = mace;
                    expectedSlot = axe;
                    inventory.setSelectedSlot(axe);
                    ((MinecraftClientInvoker) client).tripleswap$doAttack();
                    axeMaceTicks = 0;
                    axeMaceDeadline = System.nanoTime() + Math.max(0, Math.min(500, config.axeMaceDelayMs)) * 1_000_000L;
                    stage = 30;
                }
            } else if ((pearlWindPressed || pearlWindMainHandPressed) && stage == 0 && !client.player.isSpectator() && client.interactionManager != null) {
                pearlSlot = -1;
                windSlot = -1;
                for (int slot = 0; slot < 9; slot++) {
                    if (pearlSlot == -1 && inventory.getStack(slot).isOf(Items.ENDER_PEARL)) {
                        pearlSlot = slot;
                    }
                    if (windSlot == -1 && inventory.getStack(slot).isOf(Items.WIND_CHARGE)) {
                        windSlot = slot;
                    }
                }
                if (pearlSlot != -1 && windSlot != -1) {
                    expectedSlot = pearlSlot;
                    inventory.setSelectedSlot(expectedSlot);