Jump to content

Recommended Posts

Posted

Hello.

 

My mod Dynamic Tools uses the basic Enchantments but i want to make them Time/Uses Based.

 

This means they are Holding only a view Uses/Ticks and then the remove itself.

 

I want to use the function onBlockStartBreak for this.

 

but i have no clue how to remove them when you are using the item. I know i have to read the list and then delete them! But i do not know how to do this.

 

How can i remove enchantments from items? (Lists or 1 By 1)

Posted

I did override the text.

I did not mean delete enchantments from the game.

 

I only want to know how to delete them from a item like this:

 

int enchantedTime = 500;

boolean isEnchanted = true;

 

if(!entchantedtime > 0 && isEnchanted)

{

    removeEnchantments();

    removeEnchantment(Enchantment.SilkTouch, 3())

}

 

this is what i want to do.

 

Posted

idk the best way, but u can get the current tool damage and others enchantaments(if u want to remove just one of then) and then u delete, and give the same tool, set the damage to the same before and the other enchantaments.

Posted

You mean it like this:

 

public boolean onBlockStartBreak()

{

    if(ticks == 0)

    {

        --ItemStack.stacksize;

        addItemStackToInventory(new ItemStack(this, this.damage).addEnchantment(restofIt));

    }

}

Posted

You mean it like this:

 

public boolean onBlockStartBreak()

{

    if(ticks == 0)

    {

        --ItemStack.stacksize;

        addItemStackToInventory(new ItemStack(this, this.damage).addEnchantment(restofIt));

    }

}

 

 

But i do not want to make for every tool a class. I want a itemtoolclass for every basic tool.

 

There is a way to remove a list. Or something inside of the list.

So there could be a way to remove enchantment!

Posted

so get the current itemstack nbttaglist(only enchantaments use this), check to see if is not null and contains the enchantament ids that u want, and then remove. take a look at itemstack and enchantament helper

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.