Posted August 8, 201510 yr Is there any way to make an item cooldown, ex. (after using my wand I have to wait a second before I use it again.) thank you for your time: ~BoonieQuafter-CrAfTeR Im serious don't look at it!!
August 8, 201510 yr The most common are NBT and damage values. Upon using your wand set it to 0 damage, then wit the onUpdate method increase the damage value by 1. The damage bar would be an indicator to the time. When the damage is maxed, the tool is ready again. If you must use the damage for something else, then you can store an integer in the NBT of the item stack.
August 8, 201510 yr For per-item effect - indeed - store coolown in NBT and decrement it every tick. Only problem with this design that cooldown will pass only when item is in player's inventory (and maybe some other situation). If per-player - use IEED to store cooldown for item. + of this design is that cooldown is for all items of same type for given player and is always passing (even if you don't have item). It also removes NBT usage and overally is better in most cases. For wands (skills/spells) I recommend IEEP, depends on design really. 1.7.10 is no longer supported by forge, you are on your own.
August 8, 201510 yr I am using a very cheaty method I think public long thingStuffyHandler; public boolean allowInteract; public method methody(parameter, parameter2){ //on activated if(allowInteract){ doStuff(); thingStuffyHAndler = System.currentTimeMillis(); allowInteract = false; } //Update if(System.currenTimeMillis() - 1000 > thingStuffyHandler){ allowInteract = true; } } Creator of Extra Shoes Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then
August 8, 201510 yr Hi, I suggest a much more better way, using NBT of course. In the stack's NBT, set a long containing the getTotalWorldTime() and add the time in ticks you want in cooldown. Then, check if the total world time is greater than the long you just saved - If I is, the cooldown has passed. Set the long again whenever you need to - this way, you don't have to use any onUpdate method / ticker. The reason why we use the total world time instead of the current world time is because the current world is dynamic, meanin it can change when setting the time to day / night, ruining / breaking the cooldown completely. Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.