1

Need help with command block code.

BenMonkeyMommy •12/30/17 10:22 pm
•
426
•
12/31/2017 2:39 pm
I am working on a single-player world for my young son. I am trying to use a command block code to summon a villager where I have customized their trades. I would like there to be more than one trade...but right now, I am trying to get just one to work correctly.

What I am trying to spawn...a villager named Spencer that sells a heavily enchanted diamond pickaxe that I named EarthQuake(efficiency lvl 100, fortune lvl 10, silk touch lvl 1, and unbreaking lvl 10000)...and to sell it for 10,000 emeralds. The villager summons, he is indeed named Spencer...but the box where he would be asking for emeralds is blank, and the pickaxe is not enchanted or have a name.

Maybe one of my numbers (like the 10,000 emeralds) are not liked by the command block? Or I have an issue with my code. Could someone take a look at my code and tell me what I did wrong?

/summon villager ~ ~1 ~ {CustomName:Spencer,Offers:{Recipes:[{maxUses:99999,buy:{id:emerald,Count:10000},sell:{id:diamond_pickaxe,Count:1,Name:EarthQuake,ench:[{id:32,lvl:100},{id:35,lvl:10},{id:34,lvl:10000},{id:33,lvl:1}]}}{buy:{id:stone,Damage:8},sell:{id:stone,Damage:8}}]}}

Also, that last "trade" in there, I put in because it was suggested in something I watched. They said if you didn't put in that null trade...something simply useless with a damage of 8, traded for the same thing...when you would complete a trade with the villager, it would open up new (and normal) trade options. That null trade is supposed to stop that.

But anyways...please let me know if you see anything. Thank you so much!
Posted by
BenMonkeyMommy
Level 1 : New Miner
0

  Have something to say?

Join • Sign in

9

BenMonkeyMommy
• 12/31/2017 2:39 pm
• Level 1 : New Miner
Never mind...I found a fix. I added the "profession" and a "profession level" of 4 into the coding (right next to the custom name)...and tested it. The villagers gave out the sparkles like they do after they traded...but NO new trade windows opened. :) Yay!
1
BenMonkeyMommy
• 12/31/2017 2:16 pm
• Level 1 : New Miner
I have run into another problem. I traded with the villager...to test the trade, and test the tool. That part all went fine.

However, after trading, it opened all the villagers "normal" trade offers as well. The enchanted tool is still in there...but now so are all the normal trades.

As per a video I had seen, they said to put a "null" trade in there to keep that from happening. I put the coding in for a "null" trade, and had to fight with it to work right. I had to break my code down in notepad to make sure all open/close tags were accounted for, and to make sure the "null" trade was in the right place.

Anyways...got the pickaxe and null trade to show with spawned villager. So, I traded again to test it.

AGAIN...it opened the normal trades for that villager, too. It still kept the enchanted pickaxe and the "null" trade in there, but now there are all the normal trades.

HOW do I code to make it so it stays ONLY the custom trades I put the coding in for?
1
BenMonkeyMommy
• 12/31/2017 1:10 pm
• Level 1 : New Miner
@ShelLuser Omg...You do NOT know how much I love you right now! I got it to work! Mind you, I made one mistake when re-writing the code I needed (based off of what you posted)...but forget one { and all goes down hill. But it is now working. Thank you sooooo much! You have made me...and my 6 year old very happy.
1
ShelLuser
• 12/31/2017 1:25 pm
He/Him • Level 61 : High Grandmaster Senpai
Awesome! I hope you guys are going to have a lot of fun with this!
1
BenMonkeyMommy
• 12/31/2017 2:18 am
• Level 1 : New Miner
I am still having issue with it. I tried switching to asking for 40 Notch Apples (golden enchanted apples). However the ID names are golden_apple for the plain golden apples, and golden_apple:1 for the notch apples...no matter what I did, I could not get it to put the notch apples in. So, i switched to diamond blocks...and got THAT part working.

However, I still am not getting the custom name or the enchantment to show up for the pickaxe.

For the villager code, it has us doing the code quite a bit differently than if you were to just use the /give command.

And example here...

/give @p diamond_sword 1 0 {ench:[{id:16,lvl:5},{id:19,lvl:2},{id:20,lvl:2},{id:21,lvl:3},{id:34,lvl:3},{id:70,lvl:1}]}

After the diamond sword, the have the 1 0...and I don't know if that makes some difference. I have tried messing around with it too. :(
1
ShelLuser
• 12/31/2017 7:25 am
He/Him • Level 61 : High Grandmaster Senpai
Golden apple is easy, use the Damage property: buy:{id:"golden_apple",Damage:1,Count:1}. For extra item data (like enchantments) you'd use the tag:{} construct: buy:{id:"elytra",Count:1,tag:{ench:[{id:34,lvl:3},{id:70,lvl:1}]}}.

Now, I got a villager which has some silly trades, maybe its code can help you:

summon minecraft:villager 92 70 40 {Tags:["consult"],CustomName:"Job consultant",Profession:0,Career:1,CareerLevel:6,Offers:{Recipes:[{rewardExp:1,buy:{id:"skull",Damage:0,Count:1},sell:{id:"emerald",Count:3}},{rewardExp:1,buy:{id:"skull",Damage:1,Count:1},sell:{id:"emerald",Count:4}},{rewardExp:1,buy:{id:"skull",Damage:2,Count:1},sell:{id:"emerald",Count:2}},{rewardExp:1,buy:{id:"rotten_flesh",Count:32},sell:{id:"emerald",Count:3}},{rewardExp:1,buy:{id:"skull",Damage:4,Count:1},sell:{id:"emerald",Count:6}},{rewardExp:1,buy:{id:"skull",Damage:5,Count:1},sell:{id:"emerald",Count:8}},{rewardExp:1,buy:{id:"golden_apple",Damage:1,Count:1},sell:{id:"emerald",Count:16}},{rewardExp:1,buy:{id:"elytra",Count:1,tag:{ench:{id:34,lvl:3},{id:70,lvl:1}]}},sell:{id:"paper",Count:1,tag:{display:{Name:"Lifetime subscription",Lore:["Watch others fly!","Ticket never expires!"]},ench:[{id:33,lvl:3}],HideFlags:1}}},{rewardExp:1,buy:{id:"beacon",Count:1},sell:{id:"emerald",Count:12}},{rewardExp:1,buy:{id:"end_crystal",Count:1},sell:{id:"emerald",Count:4}},{rewardExp:1,buy:{id:"sponge",Count:1},sell:{id:"emerald",Count:6}},{rewardExp:1,maxUses:2,buy:{id:"prismarine",Count:32},sell:{id:"emerald",Count:6}},{rewardExp:1,maxUses:4,buy:{id:"packed_ice",Count:16},sell:{id:"emerald",Count:4}},{rewardExp:1,maxUses:4,buy:{id:"hardened_clay",Count:16},sell:{id:"emerald",Count:1}},{rewardExp:1,maxUses:2,buy:{id:"cobblestone",Count:64},sell:{id:"emerald",Count:2}}]}}
1
BenMonkeyMommy
• 12/31/2017 1:40 am
• Level 1 : New Miner
@ShelLuser You know, I don't know why I didn't think of that. Lol. I blame lack of sleep. But, I did get the idea from a server...and there, you had to use in-server currency to buy golden apples, and then trade the golden apples with the customized villagers. Given what you mentioned...I now understand why.

@bcClonEd Thanks! I shall fiddle around with it some more. :)
1
ShelLuser
• 12/30/2017 11:34 pm
He/Him • Level 61 : High Grandmaster Senpai
If you actually play the game you'll notice that there are only 2 "pay slots" available, and the maximum amount of items in one stack is 64 when it comes to emeralds. So a 10,000 count would simply be impossible.

I suggest checking out the villager wiki page, specifically the data value section. It contains all you need to know.
1
bcClonEd
• 12/30/2017 11:12 pm
• Level 1 : New Crafter
first off the highest trade value possible would be 1152 emeralds but as blocks so 128 emerald blocks. im not really sure how to get multiple trades but i would assume you just do the same thing as one but separated with a comma and with all the brackets in the right places. here's what i came up with for a trade for a pickaxe. you can change the level of the enchantments on it.

/summon villager ~ ~1 ~ {Invulnerable:1,PersistenceRequired:1,CustomName:Spencer,Offers:{Recipes:[{buy:{id:emerald,Count:64},buyB:{id:emerald,Count:64},sell:{id:diamond_pickaxe,Count:1,tag:{ench:{id:32,lvl:5},{id:34,lvl:3},{id:35,lvl:3}]}},maxUses:9999999}]}}

as a word of warning, I would not make fortune too high as it can cause some serious problems.

adding more trades or more enchantments on that pickaxe should be as simple as getting the brackets and commas right
1

Welcome