Create a Fabric mod for Minecraft 1.21.11 that fixes spear charge attacks sometimes failing to hit players/targets, allowing charge attacks to hit eligible targets as often as every tick. Investigate the actual 1.21.11 spear charge attack mechanics and implement the fix appropriately, avoiding duplicate damage within a tick and preserving normal attack behavior outside spear charging. Add server-side commands to enable/disable the fix and configure tick variance; interpret variance as the minimum tick interval between successive charge hits on the same target, default 1 tick, validate input, and communicate command usage and behavior. Persist settings if feasible and ensure server authority and multiplayer compatibility. Implement feature code only.

Kodari AI
KodariNov 1 at 6:26 pm 2
SpearChargeHitFix
Server-side Fabric mod for Minecraft 1.21.11 that fixes spear charge attacks occasionally failing to hit targets. Allows charge attacks to register hits on eligible targets as frequently as every tick while preventing duplicate damage within the same tick. Adds configurable commands to enable/disable the fix and set the minimum tick interval between successive charge hits on the same target (default 1 tick, validated input). Preserves normal attack behavior outside spear charging, persists settings, and ensures multiplayer server authority and compatibility.

Plan:

  1. Trace the 1.21.11 spear charge-hit flow and identify a server-side hook that avoids duplicate same-tick damage.

  2. Add a configurable, server-authoritative fix with validated commands and persisted settings.

  3. Wire the feature into a minimal Fabric mod entrypoint and mixin configuration.

Implemented the server-authoritative spear charge fix. It bypasses the vanilla 10-tick contact cooldown only for spear charge hits, preserves vanilla target eligibility and hit processing, and records successful hits to prevent repeat damage to the same target within a tick. Ordinary attacks remain unchanged.

Operators can use /spearchargefix to view status, /spearchargefix enable, /spearchargefix disable, and /spearchargefix variance <ticks> to set the minimum interval (1–72,000 ticks; default 1). Settings persist per world in spearchargefix.properties.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
9 423
src/main/java/dev/kodari/spearchargefix/SpearChargeFixMod.java
package dev.kodari.spearchargefix;

import net.fabricmc.api.ModInitializer;

public final class SpearChargeFixMod implements ModInitializer {
    @Override
    public void onInitialize() {
        SpearChargeFixCommands.register();
    }
}