Started by
TrilliByte
on
Topic category: Help with Minecraft modding (Java Edition)
I made this dash: Code to dash (on imgur).
Is there a way I can add a cooldown before you can dash again.
Also the code runs when you press the "C" key. The code does work but you can just fly if you spam "C".
Try to make a counter variable that will assign a value (for example, 200), and create a procedure that will work when the player's tick is updated and will subtract 1 for each tick if it is greater than 0, and your main procedure with dash will be activated only when the variable is 0.
There are couple ways you can do it.
Easiest, but worst way for preformance is if you make custom potion and if you have that potion effect you can't use ability.
Easier way is (as GGoorrllyy already explained with integer variable, I'll show diferent aproach) is to have custom boolian variable (True/False) which is set to True if you can use it or it is set to False if you can not (as example, you can just add [wait [x] ticks then on server side] procedure, which is really usefull for your situation because you can just delay procedure (and everything else should work fine).
Last but best in my opinion is to calculate time and save it in integer variable (using procedures under [Date and time] group) when will ability be ready for using again (this aproach bypasses tick checking, thich is faster for preformance).
Please someone correct me if I said something wrong/stupid xD
Btw TrilliByte can I use your code for dash for my project?