The Bug:
Switching items at the same time as attacking carries over the attributes and enchantments of the previously held item.
Among the PvP community, this is often referred to as “attribute swapping” or “breach swapping”. This bug allows you to perform attacks that shouldn’t normally be possible, therefore giving the player a severe advantage, which is unfair for other players. This works in all game modes, but can more easily be seen in survival due to the durability loss of items. This also makes it possible to do mace smash attacks with the base damage of other weapons.
Steps to Reproduce:
Give yourself some plain wooden axes along with some wooden swords enchanted with fire aspect by using the command provided below.
/give @s minecraft:wooden_axe 7/give @s minecraft:wooden_sword[minecraft:enchantments={"minecraft:fire_aspect":1}] 7Summon multiple turtles on the ground and switch into survival mode.
Attack a turtle while holding the wooden axe, and as you do this, quickly switch to the enchanted wooden sword.
If the turtle wasn’t set on fire, repeat the above steps.
Observe how the attributes (damage and attack speed) of the wooden axe were used, but the enchantments and durability of the wooden sword were also used.
Observed Behavior:
The attributes of the wooden axe were used, and the enchantments and durability of the wooden sword were also used, and the attack itself was at 100% cooldown charge despite just recently switching items.
Expected Behavior:
The attributes and enchantments of the wooden sword would be used in the attack, and the attack itself should be at 0% charge due to just recently switching items.
Linked issues
is duplicated by 14
relates to 3
Attachments
Comments 70
Is this still a concern in the latest Minecraft version 14w30c? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.
This is still a problem in 14w31a. I've updated the affected version(s) and added more screenshots to confirm.
I tested this yesterday morning. This change maybe caused by the fix of obsidian-explode sulfur cube, because the delay can provide the right block information.
I think the incompatible components and attributes affects MC28289 and MC272517 concurrently. So I delay left click after swapping for 1 tick(Exactly the way of spear-double-swapping I reported at 2025 12 31), and that reproduce these two bugs. The reset of attribute and cooldown always after item change for 1 tick somehow.
So I think maybe the plan of PaperMC will be better for two reasons:
1, It’s reasonable for pvp to swap and use new item immediately. Like blocks, pearls, wind-charges et. Delay this for 1 tick affects some operation feelings.
2, It reset the attribute and cooldown immediately when item update. Swapping and attack gets the 0 cooldown of new items.
For example, swapping to axe and attack at the same tick can still works for shield-disabling and mace-stun-smashing, but it’s 0 charged damage(20%) instead of full damage before. This can let players try to catch the timing more precisely. However, in no way should breach-swapping and spear-lunge-swapping be preserved because that bypass the cooldown designed for the item.
hey, while i don’t object to mojang fixing attribute swapping i’d like to correct a few things that SeaOfPixels got wrong:
pvplegacy is far from the most popular pvp server. see pvpclub and minemen
attribute swapping does not “narrow skill avenues down to one.” each different use of attribute swapping severely effects the execution of the swap, strategy and playstyle. consider duping tnt: the setup for duping tnt is easily recreated, but there are many different ways to utilize it, putting aside doing it effectively.
In the last comment 20260602, I forgot to explain something. Here is the supplement information. Paper refers to PaperMC, a third party software. It also fixes some old bugs that mojang haven’t fixed.
I did suggest using that fixing plan to reset attributes and cooldown instantly for better gaming experience. This result is same to what Z0rty expected in his comment 20260602. Also, both PaperMC and this mod named “Attribute Swapping Fix“ have the same fix plan. The mod’s code is available on github and modrinth. PaperMC even makes this fix as a default option since 1.21.4.
I don’t know whether mojang allow its staffs to replicate the mod’s code to fix bugs. Maybe it’s more convenient to adopt the mod’s code in to the game. If so, I need to note that:
Although it correctly reset the cooldown to 0, this plan can’t stop 4.5-blocks-reach from spear’s swapping. Due to some components of spear, they can’t fix this.
So let’s assume @Z0rty is right, changing Inventory.setSelectedSlot(…) to player.collectEquipmentChanges(…) can fix almost everything. However, spear-swapping can has 4.5-blocks-reach both as item1 and item2. So maybe there’s something wrong in spear’s components.
I know how to fix this bug now and it works finely in my game. The server needs to refresh attributes and attack cooldown instantly when items change.
In server.network.ServerGamePacketListenerImpl.class, handleSetCarriedItem method, when receive ServerboundSetCarriedItemPacket, add these methods:
resetAttackStrengthTicker() //[method from world.entity.player.Player.class, to reset attack cooldown]
CollectEquipmentChanges() //[method from world.entity.LivingEntity.class, to reset item and attributes]
doTick() //[method from server.level.ServerPlayer.class, to avoid spear problems. I'm not sure which part of this works, but without this a wooden spear can create a mace with 1.56 attack speed. And ((ServerPlayer) player).tick()、Player.createAttributes() don't work]
Vanilla cooldown bypassing, mace crits and spear lunges much faster: (with some indicators)
Now attack-swapping performs as what expected. No more cooldown bypassing. The fix, refers to mod “AttributeSwappingFix“ and I add doTick(): (with health indicators)
However, there are some problems left:
Attacking and swap to spear, the attack fail but client still plays spear stab sound. Maybe some sound event problems in client.Minecraft.class.
Holding spear, and attack-swapping, it's 0 charge attack of the new item. But it still has 4.5 blocks reach. That's because vanilla server won't check if the attack is valid. I can't fix this.
My successful rate of attribute swapping manually is about 70% and I abuse this bug in pvp servers for sure. So I know this really destroys the 1.9 attack cooldown mechanism and much worse for developing minigame items and mod servers. Glass sword in twilight forest, 40 damage, 1.6 speed, only 1 durability, but this bug can bring a mace with 40 damage, 1.6 speed, 500 durability.
I can fix MC28289 and MC272517 finally. And I finally know the main reason. The game does set the correct item, but attribute-modifiers and attackstrengthticker (a varient in Player.class) don't update timely. Not only for weapon but also for armor. Like this soul-speed-swapping (It makes player move faster permanently if don’t reload world).
My fix code is on https://github.com/EnderdragonGateway/important-bug-fix. It solves MC28289, MC147694, MC182638, MC197201, MC271336, MC271337, MC272517.
Basically, in ServerGamePacketListenerImpl.class, add these four functions like this. In LivingEntity.class, need to change collectEquipmentChanges() into public, because this function can updates attribute modifiers and don’t broke other part of codes.
Which means the game's original code in ServerGamePacketListenerImpl.class should be changed like this.
I have tried so many circumstances and don't find any problem. My fix works same to the fix in PaperMC and what expected in this ticket.
I abuse this bug in PVP and do get advantages, but I fully agree if Mojang fix this. Because it brakes the balance of 1.9 cooldown mechanics.
Confirmed.