Item cooldown locked when player disconnect then reconnect

Started by Ypermat on

Topic category: Help with modding (Java Edition)

Last seen on 10:28, 30. Oct 2023
Joined Aug 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Item cooldown locked when player disconnect then reconnect

Hello,

I am making an item that damage entities around the player when he use the item.
This effect works well.

For the cooldown I needed to use nbt tags, because even if an item (it's not a weapon) is in "minecraft" cooldown, you can still use it.
(I still use the cooldown block because it gives the item a visual effect.)
The problem is that if I disconnect, then reconnect, the item isn't in cooldown anymore, but as the timer never ended, the nbt tag is still true.
The item is now locked in cooldown.

What can I do to fix this ?
I tought of :

  • A command, but it could be abused
  • A block to "stabilize" the item, but it could be useful only if the item is locked by deco/reconnection
  • A procedure when the item is picked up, but so you could reinitialize the cooldown earlier by dropping and picking up the item
  • When right clicked in cooldown, it reset it, but so if you click it too soon players will be annoyed by the cooldown returning to maximum.

Thank you for your help !

Procedure in question (The collapsed blocks are the item effect)
Procedure in question (The collapsed blocks are the item effect)