3

I'm trying to create NPCs that allow individuals to upgrade their enchanted books beyond what is normally acquirable in survival mode. Basically the idea is that they can take two enchanted books of the same level and trade them for an enchanted book of the next level up.

(E.g. 2 enchanted books with unbreaking I in exchange for 1 enchanted book with unbreaking II)

The following code is the one I have been using to summon the villagers but there are a few issues that I have encountered.

/summon Villager ~ ~ ~ {Offers: {Recipes:[ {maxUses:1000, buy:{id:enchanted_book,Count:1,Damage:0,tag:{StoredEnchantments:[{id:34,lvl:1}]}}, buyB:{id:enchanted_book,Count:1,Damage:0,tag:{StoredEnchantments:[{id:34,lvl:1}]}}, sell:{id:enchanted_book,Count:1,Damage:0,tag:{StoredEnchantments:[{id:34,lvl:2}]}} } ]}, Silent:1 }

Firstly, I keep getting the "data tag parsing failed" error when trying to execute this command in chat. I'm assuming this is because it is too long to execute in chat since I do not have this issue when using a command block.

Secondly, after summoning the Villager with the command block, the interface is what I want, accepting two books for one. enter image description here

But when I put in the two unbreaking I books, I do not get the unbreaking II book out. It is as if the game detects the two books I have as different from the ones required by the Villager. enter image description here

Anyone can help me identify what is wrong with my code, or tell me if what I am trying to do is not possible.

Thanks!

  • Try adding type indicators in the numeric tags. Writing to NBT works without them, but testing sometimes requires them. You can also throw out your enchanted books and run /entitydata @e[type=item,c=1] {} to get the exact NBT of the item. – Fabian Röling Dec 8 '17 at 6:45
2

The command will not fit into chat, you are correct about that causing your error.

The reason the villager will not accept the books is because you are not specifying data type with the id and lvl. The villager is looking for a books with values that are stored as integers. Enchanted books values are stored as shorts when naturally generated so their values should be followed by s (id:34s).

Here is your command with correct data types:

summon Villager ~ ~ ~ {Offers:{Recipes:[{maxUses:1000,buy:{id:enchanted_book,Count:1,Damage:0,tag:{StoredEnchantments:[{id:34s,lvl:1s}]}},buyB:{id:enchanted_book,Count:1,Damage:0,tag:{StoredEnchantments:[{id:34s,lvl:1s}]}},sell:{id:enchanted_book,Count:1,Damage:0,tag:{StoredEnchantments:[{id:34s,lvl:2s}]}}}]},Silent:1}

Which then accepts the books:
Villager

  • This works like a charm thanks! Just out of curiosity, is there a way to get around the length restriction in chat without a command block? Basically the server I am trying to do this on does not have command blocks enabled. – Zotius Dec 11 '17 at 2:18
  • I don't personally know of any way. I imagine there are mods/plugins that allow it but I have never looked into it. – IronAnvil Dec 11 '17 at 3:51

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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