Problems with custom villagers and trading
Just a heads up, if I seem inexperienced in typing my question in a certain style, please forgive me!
I used a command generator, from this link, to spawn a villager who sells custom weapons.
However, the generator does not support villagers selling custom WEAPONS, only custom ITEMS. That means I have to enter the values myself, given the format provided. I have 2 more of such commands and they work perfectly fine, but only this one has a persistent problem.
Anyway, I wish to spawn a villager that trades 8 nether stars and 1 diamond for a custom pickaxe weapon, but the result was shown in the picture attached here.
This is the whole command:
/summon Villager ~1 ~ ~ {Profession:0,CustomName:"The Shop Elf #3",CustomNameVisible:1,Career:1,CareerLevel:42,CanPickUpLoot:0,PersistenceRequired:1,Invulnerable:1,Attributes:\[{Name:"generic.knockbackResistance",Base:"1f"},{Name:"generic.movementSpeed",Base:"0f"},{Name:"generic.maxHealth",Base:99999}\],Offers:{Recipes:\[{buy:{id:"nether_star",Count:5},buyB:{id:"gold_ingot",Count:1},maxUses:9999999,sell:{id:"golden_hoe",Count:1,tag:{display:{Name:"The Lucky Golden Scythe",Lore:\["Is that really gold... or just children's glitter?","You get more resources by slaying mobs."\]},ench:\[{id:16,lvl:3},{id:21,lvl:3},{id:34,lvl:2},{id:35,lvl:5}\]},MaxUses:9999999},rewardExp:false},{buy:{id:"nether_star",Count:7},buyB:{id:"dye",Count:1,Damage:1},maxUses:9999999,sell:{id:"golden_hoe",Count:1,tag:{display:{Name:"Mace of Tarrasque",Lore:\["Preserves the blood of an extinct monster.","Boosts your health dramatically."\]},AttributeModifiers:\[{AttributeName:"generic.maxHealth",Name:"generic.maxHealth",Amount:50,Operation:0,UUIDMost:30803,UUIDLeast:806745},{AttributeName:"generic.knockbackResistance",Name:"generic.knockbackResistance",Amount:1,Operation:1,UUIDMost:34336,UUIDLeast:736873}\],ench:\[{id:16,lvl:1},{id:19,lvl:3},{id:21,lvl:1},{id:34,lvl:5},{id:35,lvl:1}\]},MaxUses:9999999},rewardExp:false},{buy:{id:"nether_star",Count:8},buyB:{id:"diamond",Count:1, maxUses:9999999,sell:{id:"diamond_pickaxe",Count:1,tag:{display:{Name:"Sapphire Daedalus",Lore:\["The second most powerful weapon of the land.","Extremely high damage and health."\]},AttributeModifiers:\[{AttributeName:"generic.maxHealth",Name:"generic.maxHealth",Amount:35,Operation:0,UUIDMost:90871,UUIDLeast:499725},{AttributeName:"generic.knockbackResistance",Name:"generic.knockbackResistance",Amount:0,Operation:0,UUIDMost:66479,UUIDLeast:426152}\],ench:\[{id:16,lvl:5},{id:17,lvl:5},{id:18,lvl:5},{id:19,lvl:5},{id:20,lvl:5},{id:21,lvl:1},{id:34,lvl:1},{id:35,lvl:1}\]},MaxUses:9999999},rewardExp:false}}]}}
and this is the part of the command responsible for summoning the desired custom pickaxe:
{buy:{id:"nether_star",Count:8},buyB:{id:"diamond",Count:1, maxUses:9999999,sell:{id:"diamond_pickaxe",Count:1,tag:{display:{Name:"Sapphire Daedalus",Lore:["The second most powerful weapon of the land.","Extremely high damage and health."]},AttributeModifiers:[{AttributeName:"generic.maxHealth",Name:"generic.maxHealth",Amount:35,Operation:0,UUIDMost:90871,UUIDLeast:499725},{AttributeName:"generic.knockbackResistance",Name:"generic.knockbackResistance",Amount:0,Operation:0,UUIDMost:66479,UUIDLeast:426152}],ench:[{id:16,lvl:5},{id:17,lvl:5},{id:18,lvl:5},{id:19,lvl:5},{id:20,lvl:5},{id:21,lvl:1},{id:34,lvl:1},{id:35,lvl:1}]},MaxUses:9999999},rewardExp:false}}]}}
There must be a reason why the pickaxe doesn't appear in the trade menu, and I don't think it's a bug. I hope any experts on Minecraft data tagging could help me out; I would be really grateful!
Best Answer
Your sell tag is inside the buyB compound tag.
...buyB:{id:"diamond",Count:1, maxUses:9999999,sell:{...
You'll need to close the buyB tag after Count. Note that this probably means you have to remove a closing curly bracket somewhere else, lest you get unbalanced brackets.
There's also an additional maxUses tag inside sell, which doesn't do anything. Here's the fixed compound tag for that particular trade:
{buy:{id:"nether_star",Count:8},buyB:{id:"diamond",Count:1},maxUses:9999999,sell:{id:"diamond_pickaxe",Count:1,tag:{display:{Name:"Sapphire Daedalus",Lore:["The second most powerful weapon of the land.","Extremely high damage and health."]},AttributeModifiers:[{AttributeName:"generic.maxHealth",Name:"generic.maxHealth",Amount:35,Operation:0,UUIDMost:90871,UUIDLeast:499725},{AttributeName:"generic.knockbackResistance",Name:"generic.knockbackResistance",Amount:0,Operation:0,UUIDMost:66479,UUIDLeast:426152}],ench:[{id:16,lvl:5},{id:17,lvl:5},{id:18,lvl:5},{id:19,lvl:5},{id:20,lvl:5},{id:21,lvl:1},{id:34,lvl:1},{id:35,lvl:1}]},},rewardExp:false}
When inserting it into your command, make sure to correctly close all brackets. It should be ]}} after this to Close the Recipes list, close Offers, close the whole thing.
Pictures about "Problems with custom villagers and trading"



Why is villager trade not working?
The first thing you need to understand is that there are three types of Villagers that can't trade at all: Nitwits, Children, and Unemployed Villagers. Each have their own unique problems when it comes to trading in Minecraft. Nitwits, simply put, are too dumb to do any of the Professions in the game.Can you give a villager custom trades?
You can customize this command to make the villager trade whatever you would like. TIP: See data tags for villager to learn more about the Offers data tag. For example, replace id:leather with the item id you would like the villager to buy.Why do villagers not restock their trades?
The main cause of the restocking issue is that your villager may not have a workplace block that they can use. Without a workplace block, your villager will not be able to perform their routine restocks.Can villagers permanently lock trades?
Once a player trades with a villager, the villager keeps its profession forever and subsequently locks in the offered trades.Fixing villagers that won't trade. Minecraft
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Roger Brown, Roger Brown, Quang Nguyen Vinh, Quang Nguyen Vinh
