Add custom name on items created through commands
I'm trying to summon a villager who is buying 4 iron and selling an iron pick that can destroy iron and gold blocks. How can I add onto this command to give this pickaxe a custom nametag
/summon Villager ~-1 ~ ~3 {CustomName:Leroy,CustomNameVisible:0,NoAI:1,Offers:{Recipes:[{maxUses:10,buy:{id:iron_ingot,Count:4,Damage:#},buyB:{id:#,Count:#,Damage:#},sell:{id:iron_pickaxe,Count:1,Damage:#,tag:{CanDestroy:["minecraft:iron_block","minecraft:gold_block"]}}}]}}
Best Answer
This should work
/summon Villager ~-1 ~ ~3 {CustomName:Leroy,CustomNameVisible:0,NoAI:1,Offers:{Recipes:[{maxUses:10,buy:{id:iron_ingot,Count:4,Damage:#},buyB:{id:#,Count:#,Damage:#},sell:{id:iron_pickaxe,Count:1,Damage:#,tag:{CanDestroy:["minecraft:iron_block","minecraft:gold_block"]Display:{Name:"Weak iron pickaxe"}}}}]}}
Pictures about "Add custom name on items created through commands"
How do you give items custom names using commands?
How to Enter the CommandHow to get Items with Custom Names
More answers regarding add custom name on items created through commands
Answer 2
There were a couple things wrong with the command: the strings needed quotes, The unneeded attributes were removed, some things needed the minecraft:
namespace, and the display tag was changed to show the custom name. The Damage
attribute can be changed to make the pickaxe have more or less duribility
/summon Villager ~-1 ~ ~3 {CustomName:"Leroy",CustomNameVisible:0,NoAI:1,Offers:{Recipes:[{maxUses:10,buy:{id:"minecraft:iron_ingot",Count:4},sell:{id:"minecraft:iron_pickaxe",Count:1,Damage:200,tag:{CanDestroy:["minecraft:iron_block","minecraft:gold_block"],display:{Name:"Weak iron pickaxe"}}}}]}}
I have run this command in minecraft 1.9, and it seems to work, but if there are any problems please leave a comment.
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Maria Orlova, Anna Shvets, Tim Samuel, Tim Samuel