概览
Anti-Swap Fix 修复了一个严重的战斗漏洞,玩家可以在攻击过程中切换武器以获取非预期的属性加成。该漏洞允许玩家将一把武器的攻击速度与另一把武器的伤害或属性相结合,在 PvP 和 PvE 场景中造成不公平的优势。
本模组专为大型整合包单人多人服务器(SMP)设计,在这些环境中,玩家可以获得具有独特属性和特殊效果的武器。在这些环境下,该漏洞变得尤为严重,因为玩家可以随意组合强大的模组武器属性,完全破坏了游戏原本设定的平衡性和进度系统。
问题所在
在原版 Minecraft 中,当玩家发起攻击时,游戏会根据攻击命中瞬间手持的物品来计算伤害并应用属性,而不是根据发起攻击时的物品。这创造了一个操作窗口,让玩家能够:
- 使用快速武器(例如高攻速的匕首)开始攻击
- 在攻击过程中切换到强力武器(例如高伤害的剑)
- 在使用强力武器的同时保持快速武器的攻击速度进行伤害输出
这种漏洞通常被称为“属性交换”(Attribute Swap)或“武器交换”(Weapon Swap),会严重影响游戏平衡,特别是在拥有自定义武器或 RPG 风格战斗系统的服务器上。
工作原理
Anti-Swap Fix 采用了一种简单但有效的方法:
- 快照系统:在每个玩家刻(tick)开始时,模组记录玩家当前手持的物品
- 攻击验证:当玩家尝试攻击时,模组会比较当前手持物品与快照中的物品
- 漏洞阻止:如果物品不匹配,则取消该攻击
这种“快照-验证”策略确保玩家只能使用发起攻击时实际手持的武器造成伤害。
功能特性
- 仅服务端:无需安装客户端
- 轻量级:通过高效的快照缓存机制,对性能影响极小
- 可配置:可通过服务器配置文件或命令启用/禁用保护功能
- 调试模式:可选的单玩家调试消息,用于测试和验证
- 零误报:仅在检测到实际切换行为时才取消攻击
配置
模组会在 config/antiswapfix-server.toml 创建配置文件,包含以下选项:
[General Settings]
# 启用针对 Attribute Swap 漏洞的保护
enabled = true
# 当攻击被取消时向玩家发送调试消息
debugMode = false
命令
所有命令均需管理员权限(等级 2)。
切换保护
/antiswap toggle true/false
启用或禁用防切换保护。
切换调试模式
/antiswap debug true/false
为执行命令的玩家启用或禁用调试消息。启用后,你将收到详细消息,显示在攻击被取消时发生了哪些物品切换。
调试消息会显示:
- 刻开始时手持的物品
- 尝试攻击时手持的物品
- 便于识别的颜色编码信息
兼容性
- Minecraft 版本:1.20.1
- Mod 加载器:Forge 47.4.10+
- 运行端:服务端(客户端可选安装,但不需要)
为什么需要这个模组?
在大型整合包环境中,“属性交换”漏洞的危险性呈指数级增长。玩家可以利用以下组合进行 exploit:
- 来自一个模组的高攻速武器与来自另一个模组的高伤害武器
- 带有特殊效果的武器与具有高基础伤害的武器
- 从未设计在一起使用的附魔和自定义属性
一名手持快速匕首和强力大剑的玩家实际上可以同时拥有两者的优势,使 Boss 战变得毫无挑战,并使 PvP 完全失去平衡。Anti-Swap Fix 提供了一个干净、通用的解决方案,适用于任何物品、任何模组以及任何战斗系统。它不关心属性、附魔或特殊效果——它只是确保你使用实际手持的武器进行攻击。
致谢
作者:SatDPhoe
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:
- Start an attack with a fast weapon (e.g., dagger with high attack speed)
- Swap to a powerful weapon mid-attack (e.g., sword with high damage)
- 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:
- Snapshot System: At the start of each player tick, the mod records which item the player is holding
- Attack Validation: When a player attempts to attack, the mod compares the current held item with the snapshot
- 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
- Server-Side Only: No client installation required
- Lightweight: Minimal performance impact with efficient snapshot caching
- Configurable: Enable/disable protection via server config or commands
- Debug Mode: Optional per-player debug messages for testing and verification
- Zero False Positives: Only cancels attacks when an actual swap is detected
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:
- The item held at the start of the tick
- The item held when the attack was attempted
- Color-coded information for easy identification
Compatibility
- Minecraft Version: 1.20.1
- Mod Loader: Forge 47.4.10+
- Side: Server-side (client installation optional but not required)
Why This Mod?
In large modpack environments, the Attribute Swap exploit becomes exponentially more dangerous. Players can exploit combinations of:
- High attack speed weapons from one mod with high damage weapons from another
- Weapons with special effects combined with weapons that have high base damage
- Enchantments and custom attributes that were never meant to work together A player with a fast dagger and a powerful greatsword can effectively have both at once, trivializing boss fights and making PvP completely unbalanced. Anti-Swap Fix provides a clean, universal solution that works with any item, any mod, and any combat system. It doesn't care about attributes, enchantments, or special effects - it simply ensures you attack with the weapon you're actually holding.
Credits
Author: SatDPhoe
评论 0
登录后参与评分
还没有评论,来抢沙发吧