I'm making a map in minecraft java edition version 1.13.1 and I want to spawn a silent, invulnerable, no AI villager that trades an iron sword for a diamond pickaxe that can only break iron bars. I've tried to use the command

/summon villager ~ ~1 ~ {Invulnerable:1,Silent:1,NoAI:1,CustomName:"\"insert name\"",Offers:{Recipes:[{buy:{id:iron_sword,Count:1},sell:{id:diamond_pickaxe,},rewardExp:0b,maxUses:1}]}}

but it doesn't make the pickaxe able to break iron bars. How do I make it so that it can?

  • What have you tried so far? You just have to put the NBT of the item in the NBT of the villager trade. I think the wiki even gives you a tree view you can click through. Or look up example commands. – Fabian Röling Sep 11 '18 at 8:37
  • @FabianRöling I've tried to use the digminecraft villager trade generator, and tweak it a little. But the result makes that either it trades an iron sword for nothing, or an iron sword for just a normal pick. Could you give me an example command? I've already tried looking it up but they were all for 1.9 or earlier. – Giant Walrus Sep 11 '18 at 8:42
  • Please write the commands you tried and their behaviour into the question. And since you have an NBT tag for the sold item, just put the data of it into that. – Fabian Röling Sep 11 '18 at 10:04
  • @FabianRöling Alright. Done. I don't really know how to use NBT tags and all that. I just copy/pasted the command from digminecraft.com. Could you give me a command that might work? – Giant Walrus Sep 11 '18 at 10:50
  • You didn't put anything into the item NBT. Ah whatever, I'll just write your solution, that's easier than this discussion. – Fabian Röling Sep 11 '18 at 11:43

The tags for the item go into a tag called tag (not confusing at all):

/summon villager ~ ~1 ~ {Invulnerable:1,Silent:1,NoAI:1,CustomName:"\"insert name\"",Offers:{Recipes:[{buy:{id:iron_sword,Count:1},sell:{id:diamond_pickaxe,Count:1,tag:{CanDestroy:["minecraft:crafting_table"]}},rewardExp:0b,maxUses:1}]}}

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