I am creating this thread because I have only found a single tutorial for it and it was on a youtube video. I am going to oversimplify the code so all you have to do is fill in the blanks and paste into the command block. This work with mod items as well.
There are only two parts of this code you need to be concerned with.
buy:{id:xxx,Count:y}
and
sell:{id:xxx,Count:y}
in the "buy" portion of code, you will replace the "xxx" with the ID of the item you want the villager to purchase from you. replace the "y" with the amount of that item you want the villager to accept per sale.
in the "sell" portion of code, you will replace the "xxx" with the ID of the item you want the villager to give you in return for the item in the "buy" portion. replace the "y" with the amount of said item per sale.
I am creating this thread because I have only found a single tutorial for it and it was on a youtube video. I am going to oversimplify the code so all you have to do is fill in the blanks and paste into the command block. This work with mod items as well.
/summon Villager ~ ~1 ~ {Offers:{Recipes:[{maxUses:9999999,buy:{id:xxx,Count:y},sell:{id:xxx,Count:y}}]}}
There are only two parts of this code you need to be concerned with.
buy:{id:xxx,Count:y}
and
sell:{id:xxx,Count:y}
in the "buy" portion of code, you will replace the "xxx" with the ID of the item you want the villager to purchase from you. replace the "y" with the amount of that item you want the villager to accept per sale.
in the "sell" portion of code, you will replace the "xxx" with the ID of the item you want the villager to give you in return for the item in the "buy" portion. replace the "y" with the amount of said item per sale.
EXAMPLE:
/summon Villager ~ ~1 ~ {Offers:{Recipes:[{maxUses:9999999,buy:{id:46,Count:1},sell:{id:76,Count:5}}]}}
In the above example, the village will trade you 5 Redstone Torches for 1 TNT.
If you are confident in your abilities, you can give the merchant multiple trade options as shown below.
/summon Villager ~ ~1 ~ {Offers:{Recipes:[{maxUses:999999,buy:{id:86,Count:5},
sell:{id:388,Count:1}},{maxUses:999999,buy:{id:264,Count:5},
sell:{id:388,Count:1}},{maxUses:999999,buy:{id:388,Count:1},
sell:{id:324,Count:1}}]}}
I may do a future breakdown for more advanced merchants that will be able to offer enchanted items and such.
*be careful with the brackets! the code will not work if the brackets are not in the correct place.
*This is specifically for 1.7.10, I haven't examined the code for 1.8+ but I do remember trying to insert the item ID's into one with no success.
Best of luck!
Minecraft Item ID list with search function
https://minecraft-ids.grahamedgecombe.com/