Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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?

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.

  • Author

 

Wow, that did the trick. Thanks.

Funny thing is, I looked at that earlier today and must have just completely glanced over it.

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

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.