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.
Plan:
Trace the 1.21.11 spear charge-hit flow and identify a server-side hook that avoids duplicate same-tick damage.
Add a configurable, server-authoritative fix with validated commands and persisted settings.
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.
package dev.kodari.spearchargefix;
import net.fabricmc.api.ModInitializer;
public final class SpearChargeFixMod implements ModInitializer {
@Override
public void onInitialize() {
SpearChargeFixCommands.register();
}
}