Item with cooldown

Started by DragonOfAsparas on

Topic category: Advanced modding

Joined Apr 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Item with cooldown

Hey, i'm trying to make an item that has a cooldown just like the enderpearl in 1.9. When the item is right clicked it summons lightning (example) and then it has like 10 seconds cooldown before it can used again. Or if someone know the code for the cooldown so i can paste it in the code somehow. Anyone who has a solution?
Thanks

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I've found a WAY easier way…
Thu, 06/22/2023 - 04:17

I've found a WAY easier way to do this by using entity nbt data! 

Just add a nbt data to the player, for example : ("LghtRodCooldown", 100) and a true/false nbt statement : ("LghtRodToggle", true) when the player logs in, (join event). Then when on the right click event of the rod, (add an if statement that (if the toggle is true) summon lightning and make the current entities "LghtRodToggle" false). Then add an event for the player tick update event and make the cooldown decrease if it is not zero && if the "LghtRodToggle" is false. Then if the cooldown is zero, set the toggle to true and set the cooldown back to 100.

 

(100ticks is the equivalent of 5 real life seconds)

Yes but how

Joined Mar 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
some fun necroposting is…
Thu, 06/22/2023 - 07:58

some fun necroposting is happening here, well 

now the way for this is just to use "set item in cooldown for X ticks" inside item procedures, it blocks out some actions like right clicking, the other who aren't blocked needs to be put on cooldown manually with nbt tags