HomeJavaModsAntiSwap (Attribute Swap Fix)
AntiSwap (Attribute Swap Fix)
ModsJava

AntiSwap (Attribute Swap Fix)

by SatDPhoe · on Modrinth

Prevents players from using attribute swap exploits by fast-swapping items to their offhand. Highly configurable and perfect for Modpack, PvP and SMP…

⬇ Download on Modrinth

Overview

Anti-Swap Fix addresses a critical combat exploit where players can swap weapons mid-attack to gain unintended attribute bonuses. This exploit allows players to combine the attack speed of one weapon with the damage or attributes of another, creating an unfair advantage in PvP and PvE scenarios.

This mod was specifically designed for large modpack SMPs where players have access to weapons with unique attributes and special effects. In these environments, the exploit becomes particularly problematic as players can mix and match powerful modded weapon attributes, completely breaking the intended game balance and progression systems.

The Problem

In vanilla Minecraft, when a player initiates an attack, the game calculates damage and applies attributes based on the item held at the moment the attack connects, not when it was initiated. This creates a window of opportunity where players can:

  1. Start an attack with a fast weapon (e.g., dagger with high attack speed)
  2. Swap to a powerful weapon mid-attack (e.g., sword with high damage)
  3. Deal damage with the powerful weapon while maintaining the attack speed of the fast weapon

This exploit is commonly known as "Attribute Swap" or "Weapon Swap" and can severely impact game balance, especially on servers with custom weapons or RPG-style combat systems.

How It Works

Anti-Swap Fix uses a simple but effective approach:

  1. Snapshot System: At the start of each player tick, the mod records which item the player is holding
  2. Attack Validation: When a player attempts to attack, the mod compares the current held item with the snapshot
  3. Exploit Prevention: If the items don't match, the attack is cancelled

This "snapshot-and-validate" strategy ensures that players can only deal damage with the weapon they were actually holding when they initiated the attack.

Features

Configuration

The mod creates a configuration file at config/antiswapfix-server.toml with the following options:

[General Settings]
    # Enables protection against the Attribute Swap exploit
    enabled = true

    # Sends debug messages to players when attacks are cancelled
    debugMode = false

Commands

All commands require operator permission (level 2).

Toggle Protection

/antiswap toggle true/false

Enables or disables the anti-swap protection.

Toggle Debug Mode

/antiswap debug true/false

Enables or disables debug messages for the player who executes the command. When enabled, you will receive detailed messages showing which items were swapped when an attack is cancelled.

Debug messages show:

Compatibility

Why This Mod?

In large modpack environments, the Attribute Swap exploit becomes exponentially more dangerous. Players can exploit combinations of:

Credits

Author: SatDPhoe

ko-fi

Donate

Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

Verified by MCModsHub

These come from our own check of the pack file, not from the source page.

Explore more