Jump to content

[Solved] [1.8.9] Restricting Custom Enchants to Only Specified Item


Recommended Posts

Posted

I have a couple of custom enchants, and I have the effects for when my item is enchanted. Everything works fine in that regard.

My problem is that my enchants are being applied to vanilla items.

Currently, my custom item extends ItemBow, thus my enchants use the EnumEnchantmentType.BOW.

 

I have been looking around for a way to prevent my enchants from appearing on vanilla items, and/or for a way to specify a custom enchant type, but most tutorials/requests for help only go into adding effects to vanilla stuff (the opposite of what I want)

 

I have tried this, on suggestion from a search result:

 

public boolean canApply(ItemStack stack) {
if (stack.getItem() instanceof DTPotshot) {
	return true;
} else {
	return false;
}
}

 

And:

public boolean canApply(ItemStack stack) {
if (stack.getItem() == DTItems.potShot) {
	return true;
} else {
	return false;
}
}

 

 

But this seems do have done utterly nothing (that I can see).

 

My question is; how can I set a custom Enchant Type (if possible), or how can I prevent my enchants on going on vanilla items?

Posted
Enchantment#canApply

is only used by the

/enchant

command and the Anvil and falls back to

Enchantment#canApplyAtEnchantingTable

.

Enchantment#canApplyAtEnchantingTable

is used by the Enchanting Table and the

EnchantmentHelper.addRandomEnchantment

method (used by mobs and dungeon/fishing loot).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.