0

The setup I have is a command that will test all item frames @e[type=ItemFrame] and if an item is placed into it, I want the item to receive an enchantment, but I want it to allow any item and use only one command. Is this an option?

4
  • How can you even enchant a 'time'? – aytimothy Nov 23 '15 at 14:07
  • was supposed to be 'item' sorry, fixed in post. – Kronogenics Nov 23 '15 at 14:09
  • Your best bet is to bruteforce... Except: The problem with that is that you can't test for the item frame's contents, only the entity type (which obviously is ItemFrame). – aytimothy Nov 23 '15 at 14:12
  • I guess you can't. Even enchanting a specific Item in that way requires at least 3 commands. – Lionitow Nov 23 '15 at 14:19
2

If the enchantment is fine to be on any item, a simple /entitydata will do. Note that any enchantments that were previously on the item will be erased.

/entitydata @e[type=ItemFrame] {Item:{tag:{ench:[{id:16,lvl:1}]}}}
2
  • Well no it will overwrite any enchantment of the same, such as if it's 16 lvl 50 it would replace the lvl 50 but other then that this worked for me. – Kronogenics Nov 24 '15 at 16:28
  • @Kronogenics The entire ench tag is essentially deleted off of the old entity and replaced with the new ench tag. This happens because it's a list-type tag. It appears as though it only merges in this case, but that's incorrect. It's simply coincidence because you've specified the same enchantment type to replace. – Skylinerw Nov 24 '15 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.