R

Make a minecraft mod that toggles with ` and if you press r it does this loop:

Hold W and sprint toward target

Wait until:

Cooldown is full

Target is in reach

When ready:

Attack

Release W

Hold S for 5 ticks (small backstep)

Then press W again (re-engage + sprint reset)

Wait for cooldown

Repeat until R is pressed again.

Kodari AI
KodariFeb 13 at 8:12 pm 5,356 (v2)

I’ll create a combat automation mod with toggle controls.

CombatLooper
A client-side Fabric mod that provides automated combat assistance. Toggle the mod with backtick key and activate combat loop with R. The loop intelligently manages movement and attacks: sprints toward target, waits for full cooldown and proper range, attacks, performs tactical backstep, and re-engages. Features cooldown tracking and automatic sprint management for optimal PvP performance.

Now I’ll create the mod structure:

Created a Fabric 1.21.4 combat automation mod with backtick toggle and R-key combat loop activation. The mod tracks targets, manages attack cooldowns, sprints toward enemies, attacks when ready, performs 5-tick backsteps, and re-engages automatically until R is pressed again.

R

Its crashing upon trying to use it in game.

Kodari AI
KodariFeb 13 at 8:19 pm 11,541 (v2)

I’ll read the current files to identify the crash cause.

Looking at the code, I can identify the crash cause. The findTarget() method uses player.raycast() which only returns block hits, not entity hits in 1.21.4. Trying to cast it to EntityHitResult will crash. Let me fix this:

Fixed the crash by removing the incorrect raycast() usage for entities and adding proper null checks for client.world and client.interactionManager.

R

Critical injection failure: @Inject annotation on onTick could not find any targets matching 'tick' in net/minecraft/class_746

Kodari AI
KodariFeb 13 at 8:23 pm 5,173 (v2)

I need to examine your mixin file to diagnose the injection failure.

Analysis

  • Your mixin is empty and unused - all functionality uses ClientTickEvents.END_CLIENT_TICK

  • ClientPlayerEntity doesn’t directly override tick(), causing the injection failure

  • The mixin serves no purpose in your current implementation

Solution: Remove the Unused Mixin

The mixin has been removed. Your mod already correctly implements client ticking through Fabric’s event system in CombatLooperClient, so the mixin was unnecessary and causing the crash.

R

One question, For the hitting and moving, Are you just using packets? If so change it to like actual clicks basically, If not then its all good.

Kodari AI
KodariFeb 13 at 8:27 pm 7,309 (v2)

Good news! The code is already using actual interactions, not packets. Let me break down what’s happening:

For Attacking:

  • Uses client.interactionManager.attackEntity(player, target) - this is the proper client-side method that simulates an actual attack click

  • Followed by player.swingHand(Hand.MAIN_HAND) for the arm swing animation

For Movement:

  • Uses client.options.forwardKey.setPressed(true/false) - this simulates actual keyboard key presses

  • Same with backKey.setPressed() for moving backward

This is the correct approach. The mod is essentially simulating what happens when you physically press the W key or click on an entity - it goes through all the normal game systems (attack cooldowns, reach checks, etc.) rather than bypassing them with raw packets.

If the implementation were using packets directly, you’d see things like:

  • ClientPlayNetworking.send() calls

  • Creating packet objects like PlayerInteractEntityC2SPacket

  • Manual packet construction

But there’s none of that here - it’s all proper client-side interactions. So you’re all good! The implementation is already doing it the right way.

R

Well what if im on a server? would it show for them?

Kodari AI
KodariFeb 13 at 8:28 pm 2,422 (v2)

I need to check your current implementation to see if it’s client-only or synced to the server.

Yes, other players on a server WILL see your actions!

Your current implementation is client-side input simulation, which means:

✅ What other players SEE:

  • Your character moving forward/backward

  • Your character sprinting

  • Your attack animations and sword swings

  • The mob taking damage from your attacks

  • All effects/sounds from combat

❌ What other players DON’T see:

  • Your status messages (“Enabled/Disabled”, “Combat Active”) - those are only visible to you in your action bar


How it works: Your mod simulates key presses and attacks on your client, but those actions are sent to the server as packets (just like if you were pressing the keys manually). The server processes them and broadcasts the results to all nearby players.

Think of it like a macro or auto-clicker - you’re not modifying the game world directly, you’re just automating your inputs. The server sees it as if you’re just playing really consistently.

Important notes:

  • This works on vanilla servers without requiring the mod server-side

  • Server anti-cheat might flag the perfectly consistent timing

  • Some servers ban combat automation/macros in their rules

  • PvP servers may detect the pattern and ban you

The mod is essentially a sophisticated “hold W and spam click” automation - fully visible to everyone else!

R

When it even gets in my range, it hits, Thats just sending packets, Make it actually click and move.

Kodari AI
KodariFeb 13 at 8:31 pm 5,742 (v2)

I’ll implement realistic mouse tracking and clicking instead of packet-sending. Let me create a proper system that smoothly aims at targets and performs actual clicks.

R

Can you also add a thing for like strafing and when strafing move faster a little by sometimes jumping?

Kodari AI
KodariFeb 13 at 8:32 pm 10,654 (v2)

I’ll add strafing movement with occasional jumping for speed boost. Let me first read the current code to understand the implementation.

Now I’ll add strafing with occasional jumping for speed boost.

Added strafing with random direction changes every 15-30 ticks (left/right movement) and occasional jumping while moving (15% chance per second when grounded) for speed boost.

R

Make jumping togglable with b

Kodari AI
KodariFeb 13 at 9:18 pm 10,952 (v2)

I’ll read the existing code to understand the structure and then add a toggleable jump feature with the B key.

Now I’ll add a toggleable jump feature with the B key:

Added toggleable jumping with the B key - press B to enable/disable automatic jumping during combat, with actionbar feedback showing the current state.

R

The compilation failed with this error:

code
Validation failed for compilation: Compilation failed with 2 error(s):

ERROR in src/main/java/com/combatlooper/CombatManager.java at line 86: illegal start of expression
    private static void handleToggleKeys(MinecraftClient client) {
    ^

ERROR in   src/main/java/com/combatlooper/CombatManager.java at line 86: illegal start of expression
      private static void handleToggleKeys(MinecraftClient client) {
      ^


=== COMPILATION ERROR ANALYSIS ===

FILES TO INVESTIGATE:
  - src/main/java/com/combatlooper/CombatManager.java
  -   src/main/java/com/combatlooper/CombatManager.java
 exceeds maximum 

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariFeb 13 at 9:20 pm 5,257 (v2)

I need to read the CombatManager.java file to see what’s causing the compilation error.

I can see the problem. The file has several duplicate lines that are causing syntax errors:

  1. private static boolean modEnabled = false; appears twice (lines 17-18)

  2. updateStrafing(); appears twice (lines 58-59)

  3. private static void handleToggleKeys(MinecraftClient client) { appears twice (lines 86-87)

Let me fix this by removing the duplicates:

Fixed compilation errors by removing three duplicate lines from CombatManager.java.

Kodari can make mistakes. Review important code before using.
Files
gradle
src
.gitignore
build.gradle
gradle.properties
settings.gradle
Code
12 553
src/main/java/com/combatlooper/CombatLooperClient.java
package com.combatlooper;

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 org.lwjgl.glfw.GLFW;

public class CombatLooperClient implements ClientModInitializer {
    public static KeyBinding toggleModKey;
    public static KeyBinding toggleCombatKey;
    public static KeyBinding toggleJumpKey;
    
    @Override
    public void onInitializeClient() {
        toggleModKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
            "key.combatlooper.toggle_mod",
            InputUtil.Type.KEYSYM,
            GLFW.GLFW_KEY_GRAVE_ACCENT,
            "category.combatlooper.main"
        ));
        
        toggleCombatKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
            "key.combatlooper.toggle_combat",
            InputUtil.Type.KEYSYM,
            GLFW.GLFW_KEY_R,
            "category.combatlooper.main"
        ));
        
        toggleJumpKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
            "key.combatlooper.toggle_jump",
            InputUtil.Type.KEYSYM,
            GLFW.GLFW_KEY_B,
            "category.combatlooper.main"
        ));
        
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            if (client.player != null) {
                CombatManager.tick(client);
            }
        });
    }
}