How do I make a villager that buys a custom banner
-
I want to know how to make a villager buy custom banners and I also want to know what the problem with my code is so that I don't make the same mistake again.
This is what I typed:
/summon villager ~ ~1 ~ {VillagerData:{profession:nitwit,level:2,type:plains},NoAI:1,Offers:{Recipes:[{buy:{id:white_banner,Count:1,tag:{BlockEntityTag:{Patterns:[{Pattern:"mr",Color:13},{Pattern:"bs",Color:12},{Pattern:"cs",Color:1},{Pattern:"bo",Color:12},{Pattern:"ms",Color:15},sell:{id:gold_ingot,Count:5}]}}},maxUses:9999999}]}}
-
Here is what your NBT looks like, expanded:
{ VillagerData: { profession: nitwit, level: 2, type: plains }, NoAI: 1, Offers: { Recipes: [ { buy: { id: white_banner, Count: 1, tag: { BlockEntityTag: { Patterns: [ {Pattern: "mr", Color: 13}, {Pattern: "bs", Color: 12}, {Pattern: "cs", Color: 1}, {Pattern: "bo", Color: 12}, {Pattern: "ms", Color: 15}, sell:{id:gold_ingot,Count:5} ] } } }, maxUses: 9999999 } ] } }
The problem is that you put the data for your
sell
item into thePatterns
of the banner. You need to move it out and have it sit alongsidebuy
:{ NoAI: 1b, VillagerData: { profession: "minecraft:nitwit", type: "minecraft:plains", level: 2 }, Offers: { Recipes: [ { maxUses: 2147483647, buy: { id: "minecraft:white_banner", Count: 1, tag: { BlockEntityTag: { Patterns: [ {Pattern: "mr", Color: 13}, {Pattern: "bs", Color: 12}, {Pattern: "cs", Color: 1}, {Pattern: "bo", Color: 12}, {Pattern: "ms", Color: 15} ] } } }, sell: {id: "minecraft:gold_ingot", Count: 5b} } ] } }
When minified, the NBT you require looks like this:
{NoAI:1b,VillagerData:{profession:"minecraft:nitwit",type:"minecraft:plains",level:2},Offers:{Recipes:[{maxUses:2147483647,buy:{id:"minecraft:white_banner",Count:1,tag:{BlockEntityTag:{Patterns:[{Pattern:"mr",Color:13},{Pattern:"bs",Color:12},{Pattern:"cs",Color:1},{Pattern:"bo",Color:12},{Pattern:"ms",Color:15}]}}},sell:{id:"minecraft:gold_ingot",Count:5b}}]}}