Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

How to make something that breaks a block slowly on right click?


andreidim
 Share

Recommended Posts

Hello everyone.

I am working on a mod and I hit a little break, I need to make something that breaks a block slowly like a tool but when the person presses right click.

I think it's OP to make an item that breaks stuff every tick.

If anyone uses Thaumcraft, they should know about the wand of excavation or how it's called in the new versions, I haven't done mods in a while.

I would like to have something that works kinda like that, how could I do that?

Link to comment
Share on other sites

I have the thaumcraft source and he use onItemUse and just break the block instant. And there is no cool down or something.

 

But you could make it like this that you add with itemNBT a custom cooldown.

 

like this: Note its a custom Function you only need to call it in the onItemUseFunction

public boolean onItemUseage(ItemStack stack, World world, int x, int y, int z) //More is
{
      if(stack.hasTagCompound())
      {
           NBTTagCompound nbt = stack.getTagCompound().getCompoundTag("tool");
           if(nbt.getInteger("coolDown") <= 0)
          {
                 //Here do your break code
                 nbt.setInteger("coolDown", 20);
                 return true;
          }
      }
      return false;
}

public void onUpdate(ItemStack stack, World par2, EntityPlayer player)
{
     if(stack.hasTagCompound())
     {
          NBTTagCompoun nbt = stack.getTagCompound().getCompoundTag("tool");
          if(nbt.getInteger("coolDown") > 0)
          {
                int between = nbt.getInteger("coolDown");
                nbt.setInteger("coolDown", between-1);
          }
     }
}

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.

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

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.