Jump to content

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


Recommended Posts

Posted

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?

Posted

You could try to create some sort of cooldown before the block is harvested.

I'm always happy to help others!

 

Java is not my main programming language but I have alot experience in PHP/HTML/JS/CSS3/C#/SQL

Posted

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);
          }
     }
}

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.