Posted February 16, 20214 yr 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?
February 16, 20214 yr Author 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.
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.