mojira.dev
MC-87227

Switching a weapon with "low cooldown" to a weapon "high cooldown" resets cool down bar after a bit of charging

The bug

So apparently if you switch from a "short cooldown" item, such as the Hoe, to a "high or medium cool down" item, such as the Sword, both bars, crosshair and hotbar, seems to be buggy. (This does work even if you switch from the hand to a weapon).

By "buggy" i mean that the cool down bar at first seems to charge but it instantly refreshes and re-charge from the beginning. ( If you go into the game you will certainly notice it).

Code analysis

Based on 1.11.2 decompiled using MCP 9.35 rc1

It looks like the value of the field net.minecraft.entity.EntityLivingBase.ticksSinceLastSwing is reset client-side, however attributes like net.minecraft.entity.SharedMonsterAttributes.ATTACK_SPEED are set server-side. Therefor the client probably starts increasing ticksSinceLastSwing with the old attack speed and then receives the attack speed for the new item from the server which makes the recharge progress appear to jump.

Linked issues

Attachments

Comments 22

What do you mean by buggy? Please explain the issue in more detail and provide exact steps to reproduce.

I mean that the cool down bar resets after a bit of charging (when you switch from "short cooldown" to "high cooldown")

I think this has been in 1.9 for months. I can confirm this and I'll re-word the problem. When switching from a 'low cooldown' item (such as an empty hand) to a 'high cooldown' item (such as a Diamond Sword switching from an empty hand, for example) when that higher cooldown item first starts charging, it goes about a quarter way then starts charging again, the in-hand animation also shows this according to the state of charge.

I've uploaded a video of the issue here: https://youtu.be/YPTi_gjIh4s

You can see how when you switch from the empty hand (low cooldown) to the Diamond Sword (high cooldown) the Diamond Sword charges to about a quarter way, then restarts charging.

(I can confirm for 1.9 (pre-3)). I forgot to mention that sometimes that when this happens the in-hand animation doesn't show accordingly to the hotbar charge meter (for example the third time changing from empty hand to Diamond Sword in the video).

12 more comments

Confirmed for 21w14a.

Can confirm in 1.17.1.

Can confirm in 24w14a. I would like to request ownership of this issue, specifically because of it's lack of upkeep since 1.17.1.

Here is a video demonstrating the issue:

[media]

@Jiingy yes please fix this. I have just discovered this issue on my PvP server and it is entirely game balance breaking. Client side mods can easily abuse this to turn slow swinging weapons/tools into near-instant cooldown weapons. Feel free to contact me for bug testing/fixing. 

@unknown, bug tracker helpers and moderators are not Mojang employees, so they can't fix bugs.

Lorenzo

[Mod] Jingy

(Unassigned)

Confirmed

Gameplay

Low

Combat

attackSpeed, item

Minecraft 15w35b, Minecraft 15w44b, Minecraft 15w50a, Minecraft 1.9 Pre-Release 3, Minecraft 16w42a, ..., 1.16.4, 21w14a, 1.17.1, 1.20.5 Pre-Release 1, 1.20.5

Retrieved