Jump to content

Recommended Posts

Posted

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.

Posted

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?

Posted

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

 

 

:)

 

-TGG

 

Ok the cooldown is working now, but its not shooting projectiles anymore

How do you do?

Posted

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.

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.