Posted October 31, 201410 yr A HUGE thanks for everyone that helped me with this, it's now working! How do you do?
October 31, 201410 yr Soo its pretty simple how a cooldown works. In your onItemRightClick method you would want to do something like this private int coolDown = 0; @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { if(coolDown <= 0) { player.motionY = 2; coolDown = 100; // Cool down time in ticks } } Then you will need to override the onUpdate method allowing the cooldown to count down. @Override public void onUpdate(ItemStack itemstack, world world, Entity entity, int i, boolean B) { if(coolDown > 0) coolDown--; } Soo yeah, Its pretty simple all your doing is making it count down in ticks so a player cant use it. You will want to add a if() statement to see if the cooldown is completed so the player can use the item again.
October 31, 201410 yr Why not use the itemDamage for that? then you would also have somewhat of a visual effect for the cooldown (I think you can disable it if u dont want it)
October 31, 201410 yr There you go ^^ https://bitbucket.org/Dragonisser/cobaltmod/src/178c28c1f444b11466696e40bcbfb0f8978acf76/cobaltmod/items/ItemWindAxe.java?at=master
October 31, 201410 yr Author Why not use the itemDamage for that? then you would also have somewhat of a visual effect for the cooldown (I think you can disable it if u dont want it) How exactly do I do this? How do you do?
October 31, 201410 yr Why not use the itemDamage for that? then you would also have somewhat of a visual effect for the cooldown (I think you can disable it if u dont want it) How exactly do I do this? There you go ^^ https://bitbucket.org/Dragonisser/cobaltmod/src/178c28c1f444b11466696e40bcbfb0f8978acf76/cobaltmod/items/ItemWindAxe.java?at=master There you go ^^ -TGG
October 31, 201410 yr Author Its working now... sort of. Its not shooting projectiles. Here is what I did. http://pastebin.com/hdwXZdTi How do you do?
October 31, 201410 yr Author Why not use the itemDamage for that? then you would also have somewhat of a visual effect for the cooldown (I think you can disable it if u dont want it) How exactly do I do this? There you go ^^ https://bitbucket.org/Dragonisser/cobaltmod/src/178c28c1f444b11466696e40bcbfb0f8978acf76/cobaltmod/items/ItemWindAxe.java?at=master There you go ^^ -TGG Ok the cooldown is working now, but its not shooting projectiles anymore How do you do?
October 31, 201410 yr Hi I think the problem is that you've copied bits of Dragonisser's code without really understanding what it's doing? This bit for example.. if (par1ItemStack.getItemDamage() > 0) { entityplayer.fallDistance = 0.0F; } The key bit from Dragonisser's code is that he is using the ItemDamage as a counter. The rest is irrelevant to you. So to troubleshoot the cooldown problems you're having, I think the best way is to add a diagnostic to your code, you can see Dragonisser already had one there which for sure will help a lot So for example if (par1ItemStack.getItemDamage() < par1ItemStack.getMaxDamage()) { par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1); System.out.println(par1ItemStack.getItemDamage()); // uncomment this line } and if (player.capabilities.isCreativeMode || player.inventory.hasItem(Items.arrow)) { System.out.println("Attempt to fire stack " + stack + " with getItemDamage() == " + stack.getItemDamage()); // add this in if (stack.getItemDamage() == 0){ player.inventory.consumeInventoryItem(Items.arrow); //stack.attemptDamageItem(damageItem, itemRand); Then look in the console for the diagnostic information and see what happens when you try to use the wand. -TGG
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.