Jump to content

[1.16.4] Making two custom enchantments incompatible with each other


Peppy8651

Recommended Posts

Let's say that I have two custom enchantments for the same item. I made a custom ItemSword that let's you shoot fireballs when you right click, and I made two enchantments that modify that fireball. What I want is to make these two enchantments incompatible with each other. An example would be me putting one enchantment on my sword. Then, when I go on an anvil, I would not be able to apply the other enchantment unless the first enchantment was gone. I would also like this to work vice versa. My enchantments both extend Enchantment. I tried overriding Enchantment#isCompatibleWith() but it's a final method. Therefore, how would I be able to make two custom enchantments incompatible with each other?

Link to comment
Share on other sites

19 minutes ago, diesieben07 said:

canApplyTogether is the method you need to override. isCompatibleWith is what needs to be called, as it checks "both sides" (look at the code, its obvious).

Thank you so much! I don't know how but I could not find the method canApplyTogether using Eclipse (That square thing that pops up when you type something and shows you classes and methods) but I guess it does exist because I was able to override it and it worked.

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