Posted March 19, 201312 yr 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; }
March 20, 201312 yr 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.