1

I have a small server with my friends, and we want to remove mending from play. I was thinking it will be easy now to just place a command block which looks on players inventory and removes enchantment books with mending on it.

But I can't create that command, I was trying this various:

/clear Excidium minecraft:enchanted_book{Enchantments:[{id:"minecraft:Mending"}]}
/clear Excidium minecraft:enchanted_book{Enchantments:[{id:"minecraft:Mending",lvl:1}]}
/clear Excidium minecraft:enchanted_book{Enchantments:[{id:"minecraft:Mending",;lvl:1s}]}
clear Excidium minecraft:enchanted_book{StoredEnchantments:[{id:mending,lvl:1}]} 1

And nothing happened.

When I use the command /give Excidium minecraft:enchanted_book{StoredEnchantments:[{id:mending,lvl:1}]} 1 to give myself a book with mending, then I can remove it from the bag. But when the mending book is from another source like villager, chest, fishing, ect, the command doesn't work. The mending book is still in the inventory.

Please help.

1
  • Hey, make sure you always put commands and coding into code format by clicking the brackets in the editor, that way your question will be more organized.
    – ahmettrPro
    Commented Jul 19, 2020 at 23:26

2 Answers 2

1

Basically, make sure you're not putting all of the commands in a single command block.

If that's good to go, then you should also know that you don't need the first 3 lines of commands, since enchantment books' enchantments are always stored in the StoredEnchantments:[] NBT tag.

Another problem is that you're checking for a single player. Use @a to clear all players' inventories of said item.

That said, you should also take note that items that have the Mending enchantment will not be cleared. You'll have to clear them seperately one by one using seperate command blocks. (e.g. /clear @a golden_pickaxe{Enchantments:[{id:mending,lvl:1}]})

1
  • I guess I gave it not entirely good. These are various attempts to use this command on me And none brings the desired result. When I manage to do a command that removes the item, I will change the target to everyone Commented Jul 20, 2020 at 5:13
1

Always use this command to check what data an item has (while holding it):

/data get entity @s SelectedItem

That basically tells you the solution already:

{id:"minecraft:enchanted_book",Count:1b,tag:{StoredEnchantments:[{lvl:1s,id:"minecraft:mending"}]}}

Since you can only naturally get level 1, lvl don't matter for you, so it's this:

/clear @a enchanted_book{StoredEnchantments:[{id:"minecraft:mending"}]}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .