"Apply cooldown on <item> to provided player" procedure block

Upvotes: 4
Issue description

It's possible to apply the vanilla cooldown (see enderpearls) on any item with this line of code:

playerIn.getCooldownTracker().setCooldown(Item item, int duration);

where "duration" is measured in ticks.

Issue comments

Developer Submitted by Klemen on Wed, 09/11/2019 - 07:51

Thanks for the code example, I will consider implementing this.

But there is another way to make a cooldown for items:

  1. Use NBT variable to store cooldown info
  2. On item in inventory tick update or in hand tick update, decrement the value of the NBT variable by one, until it is 0, then stop decrementing
  3. In on item used, check if the variable is 0 and in this case, perform item action and set the counter to say 100 for 5 second cooldown (20 ticks = 1 second), otherwise do nothing

There are some cases where this can not be used so I will definitely test your code too and try to add it.

Developer Submitted by Klemen on Thu, 09/12/2019 - 10:07

This feature will be added in 1.9.1, I am closing this ticket now.