Jump to content

Item usage delay


Recommended Posts

Hi, is there any way to delay the amount of times an item is used? I want this to be able to be used every other second instead of spammed. My code right now is this, but it doesn't work.


//In the super, lastShotTime is declared as currentTimeMillis()
public ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3)
                //delay time is 1000, but it fires extremely rapidly

	long now = java.lang.System.currentTimeMillis();

	if (var3.inventory.hasItem(FalloutMain.a357.itemID));

		if( now > lastShotTime+ delayTime )
			EntityLaserLR var4 = new EntityLaserLR(var2, var3, 20.0F, true);
			var4.canBePickedUp = 0;
			var2.playSoundAtEntity(var3, "blfngl.357Fire", 2.0F, 1.0F);
			lastShotTime = now;
	return var1;


Link to comment
Share on other sites

you cannot have "dynamic" stuff in Item class. every item in game has just 1 Item (inheriting) class. you have to work with NBT in ItemStack if you want to have different lasers (or what the item is) on different cooldowns. also I think your code should not run on a client AND on a server (spawning entities on a client side is not good).

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

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.

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.

  • Create New...

Important Information

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