#How to get rid of custom enchantments on pre-existing weapons

1 messages · Page 1 of 1 (latest)

young plinth
#

I want to update my custom enchantment pack to have two enchants become incompatable which each other, and pre-exisiting weapons with these enchants I want incompatable to be removed from those weapons

worn anvilBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

#
⚠️ You already have a question open!

Don't forget to close or resolve your old questions once you're done with them. It makes our lives much easier! :D

Open question: #1296203192991879217

worn anvilBOT
# worn anvil <@&1201956957406109788>

<@&1166082198152159386> <@&1202694677766348840>

🙇 Helpers Arise!

Please note that you still might not immediately get a response since all helpers are human beings and volunteers (and also might be sleeping right now)

young plinth
#

ok 👍

fiery prism
#

To make two enchantments incompatible with one another, you just need to define for both of them an exclusive_set, which will just be the other enchantment (and/or any other enchantments you want them to be incompatible with)

#

Removing the incompatible enchantments from existing items is quite a bit harder

lapis crest
#

ye you can see that you can give yourself an infinity mending bow with commands

#

the game only checks them in anvils

young plinth
#

i know how to make them incompatable, im wondering how to remove the incompatible enchants from previous existing items

fiery prism
#

OK, well you asked how to make them incompatible too.

young plinth
#

i can see how that can be misunderstood for but no im only asking about removing incompatable enchants from existing items

fiery prism
#

And that's pretty challenging to do, especially while retaining any other enchantments they have

young plinth
fiery prism
#

Let me be absolutely clear then: What we were trying to say is that there isn't going to be a way to do this without pretty significant trade-offs, either to the behavior or to your time and effort.

The way you'd need to do this is with item modifiers and /execute if items checks. If you want to preserve all of the enchantments that the item has that aren't incompatible, the simplest way would be:

  1. Have a ticking command that runs a function as all players
  2. In that function, for each slot that items with those enchantments could appear in from among the four armor slots, and both hands, run yet another function if that item has both of the incompatible enchantments via an if items check.
  3. In that function, individually check if that item has each possible enchantment, and somehow store that true/false data somewhere, along with what level it was. Could be a scoreboard or storage, whatever works for you.
  4. Clear all of the item's enchantments.
  5. Then, for each enchantment it had, except the incompatible enchantments, use a set_enchantments item modifier to give it that enchantment at that level
  6. Finally, somehow determine which of the incompatible enchantments you want it to keep, and use an item modifier to add that back, too.

The main trade-offs here are an incredible amount of item modifiers and if items checks, and no reasonable way to handle preserving custom enchantments from other data packs or mods. It's possible this could be eased using macros and in-line item modifiers, but I'm not well versed enough in macros to guide you through that process.

young plinth
#

would just making a new enchant that does the same thing and removing the old one work or would that cause issues?

#

or is what you said the only way..

fiery prism
#

I'm not sure if that would work, it's possible it could corrupt the world or those items

#

But it also might just remove the old enchantment, so could be worth a try. Just make a backup first

young plinth
#

okay if that doesnt work ill find a way to do your method