r/MinecraftCommands • • 2d ago

Help | Java 26.3 Cooldown

Heyo! Anyone know how to put a cooldown on a spear when you left click with it? I tried the command below while in survival but it didnt give a cooldown :T

/give @.a iron_spear[enchantments={lunge:2},use_cooldown={seconds:10}]

6 Upvotes

2 comments sorted by

1

u/Ok_Message_6051 Command Rookie 1d ago

I also once wondered about the cooldown for equipment. Unfortunately, the mechanics aren’t designed for that, and it’s not possible to implement it properly. The only thing I came up with is to replace the item with an consumable one at the right moment, which will restore the original item after consumption. But this method requires a mandatory right‑click to “reload” the item

1

u/thedemontuanmc 10h ago

use_cooldown only fires when the item is used (right click), and the spear's jab (where Lunge triggers) is an attack, so it never applies there.

For a cooldown on the left-click attack you can use the attack charge instead: minimum_attack_charge=1.0 means the jab only goes through when the attack indicator is full, and a very low attack speed makes it take ~10 seconds to fill:

/give @s iron_spear[enchantments={lunge:2},minimum_attack_charge=1.0,attribute_modifiers=[{type:"attack_speed",id:"spear_cd",amount:-3.9,operation:"add_value",slot:"mainhand"},{type:"attack_damage",id:"spear_dmg",amount:4,operation:"add_value",slot:"mainhand"}]]

Player base attack speed is 4, so -3.9 leaves 0.1 attacks per second = 10 s. Setting attribute_modifiers replaces the spear's default ones, so add the damage back yourself (tune the 4). Side effect: the attack indicator shows the cooldown, which is kind of nice.