Jump to content

[1.8.9] Making a timer?


Recable

Recommended Posts

How would I make a timer? For example I right click my sword using the onItemRightClick method it then gives me strength 3 for 5 seconds, now how would I make it so this effect won't activate again even when right clicked for 15 seconds?

Link to comment
Share on other sites

Compare written world time to the currnet world time + delay amount.

If greater:

Do your effect and write the current world time to the ItemStack's NBT.

Else:

Do nothing

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Time is kept in ticks, 20 ticks to the second. If you can add a tick counter to your item stack or player entity, then you could count down 300 ticks before allowing the special ability again. See how other cool-downs are implemented.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

That causes updates to the itemstack every tick, which isn't efficient.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Compare written world time to the currnet world time + delay amount.

 

While I don't have anything against timestamps - you also need to secure NBT timestamp for multi-dimensions.

 

That causes updates to the itemstack every tick, which isn't efficient.

 

It is, if you use @Capability :)

Said that - timestamp can often be better, but for short timers I prefere caps.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.