"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

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.

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

Donate to MCreator

By donating to developers you can speed up development, as with more resources, we can dedicate more time to MCreator. It is a free project made by developers working on it in their free time.