Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.setDamage(1.0D);
			var4.canBePickedUp = 0;
			var4.setRandom(15.0F);
			var2.playSoundAtEntity(var3, "blfngl.357Fire", 2.0F, 1.0F);
			var2.spawnEntityInWorld(var4);
			lastShotTime = now;
		}
	}	
	return var1;
}

 

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.