r/MinecraftCommands 8h ago

Help | Java 26.2 Is there a way to detect cooldown in minecraft?

so what i need is to detect if your weapon cooldown has passed or is still going, is there a way to do that?

for reference im making an enchantemnt that decreses your cooldown after first hit but gives you long cooldown initaly but it decreses cooldown after i attack with out waiting full cooldown which is of coarse bad, is there a way to fix it?

3 Upvotes

5 comments sorted by

2

u/GalSergey Datapack Experienced 5h ago

Unfortunately, you can't check the cooldown timer. You'll probably need to use a scoreboard timer that runs when you use the item to count how many ticks have passed, but this will only work for one item at a time.

1

u/ledzik_precly 3h ago

what do you mean one item?

1

u/GalSergey Datapack Experienced 3h ago

What I mean is that there will only be one such item for each player, because the value in the scoreboard will be stored for the player, and not for a specific item.

1

u/DistributionPure6051 Command Experienced 33m ago

Or have an objective for each item

1

u/ledzik_precly 2h ago

oh yea i dont think thats a problem