Trading

The trading system is a gameplay mechanic that allows players to trade emeralds for items (and vice-versa) with NPC villagers. {| class="toc" id="toc" style="font-size:12px;border-color:rgb(170,170,170);"

Contents
[hide]  *1 Functionality
 * 2 Possible offers
 * 2.1 Farmer
 * 2.2 Librarian
 * 2.3 Priest
 * 2.4 Blacksmith
 * 2.5 Butcher
 * 2.6 Villager (green clothes)
 * 2.7 Notes
 * 3 Video
 * 4 History
 * 5 Issues
 * 6 Trivia
 * 7 Gallery
 * 8 References
 * }

[edit] Functionality
Right-clicking a villager will open a GUI allowing a player to trade with the villager. Villagers will make offers based on their profession, and will only make trades based on what offers they are making. Different offers may be viewed by pressing the left and right buttons next to the currently displayed offer. All offers involve emerald as a currency, and some item pertinent to the villager's profession. Trading allows the acquisition of uncommon items that would otherwise be fairly difficult to obtain, such as chainmail armor. It is also the only legitimate method of acquiring bottle o' enchanting in Survival mode.

A villager will never offer to buy/sell the same item at different prices or quantities (for example, no villager will offer to buy either 16 raw pork or 17 raw pork: there can only be one offer to buy raw pork). However, the quantities and prices may vary from villager to villager, and a villager's own quantities/prices may change when they generate new offers.

All villagers initially have only one offer to make. They can generate new offers when the last offer available (rightmost on their list of offers) has been traded at least once. Note that the trading GUI must be closed before a villager will generate a new offer. When they do, they become surrounded with purple particles for a moment. New offers may involve items a villager was already buying/selling: in this case, the newly generated offer will overwrite the previous one, allowing a villager's prices (or priest's enchantments) to change. Although there is no maximum limit on the number of offers an individual villager can make, they can only have one offer for each type of item they can trade. In addition, when a villager already has many offers, there is a high probability that a newly generated offer will be of an item they already offer: thus the old offer will be overwritten, and there will not be any new offer slot added to the villager.

Villagers will deactivate an offer if the offer has been used some number of times and it is not the villager's only offer. The chance of an offer's deactivation is random, but an offer must be used at least 3 times before it is eligible for deactivation. After an offer has been used 13 times, it is guaranteed to be deactivated if you close the interface after trading it (this is true even if all 13 trades have been done at once). Trading the last offer may activate an offer again.

Prior to the Pretty Scary Update (v1.4), it was possible to trade more than 13 times on a single offer because offers were not removed until the trading interface had closed. This meant you could buy an offer as many times as you could afford with one inventory. Currently, villagers can halt trading on a particular item once the conditions for deactivation have been met even if the trading window is still open. This can cause strange behavior in inventory when player is using shift and click when trading. At first it seems that all goods have been traded, but after taking an action in inventory the amount of emeralds and goods in user inventory changes. Once the trading window is closed and reopened, the offer will still be displayed, but red X's will indicate that the offer is no longer available. However, only one offer can be removed after the trading interface is closed: if you trade multiple offers beyond the limit, only the last one traded will be removed. In this way, an offer with more than 13 uses can be kept, and the game does not check offers for disabling until the offer is traded.

In addition, if an offer is the last offer available, it is never disabled even if its uses exceed 12. Once it is no longer the last offer, of course, it is eligible for being disabled. When an offer is disabled, it has the same particle effect as an offer being created.

Unfortunately, though, you cannot change what a villager will sell, so you will have to trade until all items are unlocked.

[edit] Possible offers
Quick reference trading chartThe following table lists the minimum and maximum offers that a villager will make when buying and selling items. === [edit] Farmer===

[edit] Villager (green clothes)
''Note: The green Villager is only obtainable using server commands, mods, or third-party map editors. It does not spawn naturally, even when using a spawn egg.''

[edit] Notes

 * 1) ↑ Most offers have a probability value defined in the code. The larger the number is, the more likely the offer is. This is not exactly the probability of getting the offer: the game first compiles a list of potential offers, and the probability is used to determine whether the offer is included in this list. Then one offer is selected from this list at random to be the actual new offer generated.
 * 2) ↑ The actual probability of an offer depends on the probability values of all offers for a villager. These values were calculated by checking the probabilities of all possible lists of potential offers.
 * 3) ↑ a b c d e f Gold ingot offers do not have a probability value in the code, except for one of the two blacksmith offers. If no potential offers are generated, then the game will default to an offer of gold ingots. Note that this offer is more likely when all other offers have a low probability.
 * 4) ↑ The enchantment is chosen randomly, with equal chance of any enchantment type occurring and equal chance to get any level of it, so higher-leveled enchantments are as likely to get as low-leveled enchantments. The price in emeralds depends on enchantment level only. The possible values are 5 – 19 emeralds for Lvl I, 8 – 32 for Lvl II, 11 – 45 for Lvl III, 14 – 58 for Lvl IV and 17 – 71 for Lvl V.
 * 5) ↑ Priests will offer to enchant items for you. Every enchantment costs between 2 – 4 emeralds, and requests the item to be enchanted in the first slot. Trading for an enchanted item in this manner repairs the item if it is damaged, allowing items to have infinite durability at the cost of emeralds. When creating the enchantment offer, the game uses a random enchantment level from 5 – 19. For a listing of what enchantments will show up at these levels, see Enchantment Mechanics
 * 6) ↑ The blacksmith actually has two chances to offer to buy gold ingots. This is because it is an explicit offer a smith may ordinarily make (0.5 probability value, or 6.6765% chance), and it is also a default offer for all villagers (with a 0.0052% chance from a blacksmith). Note that, despite two chances to generate a gold ingot offer each time an offer is generated, a blacksmith will never have two separate offers to buy gold ingots in the trading interface, because the offers involve the same items.
 * 7) ↑ "Price per Unit Ingredient" is the equivalent price per diamond gem or iron ingot that you would be paying if you were buying the diamonds or iron and then crafting the resulting tool or armor yourself. In the case of chainmail armor, these numbers are given for a theoretical comparison only, since chainmail cannot be player-crafted. In the case of tools, sticks used in the crafting of tools are ignored in the calculation.

[edit] Video
 ==History== The first image of the trading system released by Jeb.[1]  The currency item (later updated to the emerald) can be seen in the inventory.Before the Adventure Update, Notch once answered some questions about an idea he had, NPC Villages, where he revealed some thoughts about them:[2] On May 21, 2012, Jeb released a screenshot of himself testing the Trading System.[1]  The image shows a GUI with buying and selling areas. The bottom area allows the player to sell various items for currency, whereas the top area uses this currency to purchase items. A possible way to buy them would be to put these currencies in the left slot, where the chicken is, and you can scroll through items for the right slot to take the item you choose once you click on it. The player may use the arrow buttons to scroll through a villager's inventory and select the desired item. Jeb also mentioned that this may be an end to non-renewable resources, supposedly as most can be bought for some price from NPCs. In the image, a red currency item can be seen that was later revealed in snapshot 12w21a as a ruby item that was changed to emerald before 12w21a, for reasons unknown.
 * If you treat the villagers well (giving them items), they'll give you items back.
 * If you treat the villagers badly (attacking/killing them), they'll try to do the same to you (feature added with Iron Golems).
 * Raiding chests will anger the owners of the town/chest and they will attack.

<p style="margin-top:0.4em;margin-bottom:0.5em;line-height:19.1875px;font-family:sans-serif;">An ore block can be seen in the background which was later revealed in snapshot 12w21a to be Ruby Ore, which was changed to emerald ore before 12w21a because Dinnerbone is colorblind<sup class="reference" id="cite_ref-9" style="white-space:nowrap;">[3].

<p style="margin-top:0.4em;margin-bottom:0.5em;line-height:19.1875px;font-family:sans-serif;"> by Jeb shows separated villagers.<sup class="reference" id="cite_ref-10" style="white-space:nowrap;">[4]  This tweet also says "this is how I experiment with villagers". With spawn eggs for spawning random villagers, one would think that by keeping them separate Jeb was testing each profession of the villagers, perhaps because they each trade different items or would be.

<p style="margin-top:0.4em;margin-bottom:0.5em;line-height:19.1875px;font-family:sans-serif;">With the implementation of the trading system, most or all resources become "renewable" since nonrenewable resources can be traded from villagers.<sup class="reference" id="cite_ref-11" style="white-space:nowrap;">[5]

<p style="margin-top:0.4em;margin-bottom:0.5em;line-height:19.1875px;font-family:sans-serif;">As of snapshot 12w22a, Priests no longer offer to buy Rotten Flesh or Eyes of Ender. Eyes of Ender are now sold by priests, and rotten flesh is not a trade at all.

<p style="margin-top:0.4em;margin-bottom:0.5em;line-height:19.1875px;font-family:sans-serif;">The trading UI has been changed where an extra input space has been added where tools can be placed for buying enchantments and/or repair.

<p style="margin-top:0.4em;margin-bottom:0.5em;line-height:19.1875px;font-family:sans-serif;">Prior to snapshot 12w23a, the probability of a librarian buying a written book as a potential offer was 1.3 (130%), meaning it would always be a potential offer. This meant it was impossible for librarians to offer to buy gold ingots, as this is a default offer which occurs if no offers are put on the list of potential offers. This has been corrected in snapshot 12w23a.

<p style="margin-top:0.4em;margin-bottom:0.5em;line-height:19.1875px;font-family:sans-serif;">In update 12w32a, trading was adjusted further. The librarian's paper offer was adjusted to 24-35 paper per emerald, and the farmer's arrow offer was corrected to 9-12 per emerald.

<p style="margin-top:0.4em;margin-bottom:0.5em;line-height:19.1875px;font-family:sans-serif;">In addition, the offer probability mechanic was changed: as more offers exist for a villager, the probability of all offers rise. When an offer's probability goes beyond a certain limit, its probability goes down. The net effect is that rarer offers become more common when a villager has many offers, and common offers become rarer.

<p style="margin-top:0.4em;margin-bottom:0.5em;line-height:19.1875px;font-family:sans-serif;">In addition, the offer removal mechanic has been replaced with an offer disabling mechanic: all offers begin with 7 'uses', allowing the offer to be traded up to seven times. After this, even if the player has not left the trading GUI, the offer is disabled - if a player has shift-clicked in an attempt to trade more than the limit, the items temporarily appear in the inventory but vanish as though the excess trades never happened. If a player trades the last offer on the list and closes the GUI, waiting for particles to appear around the villager, all disabled offers are renewed with 2-12 additional uses added to them. Due to the random distribution, the average amount of uses added is 7, and the amounts are weighted towards values in the middle of the range. Note that offers which are not disabled do not get extra uses. It is possible for the final offer slot to be disabled, at which point no new offers can be generated and no existing offers can be renewed.

<p style="margin-top:0.4em;margin-bottom:0.5em;line-height:19.1875px;font-family:sans-serif;">Finally, trading with the last offer slot available will increase your popularity with the village by one point. Note that your popularity applies to the village as a whole, and other players' popularity is not affected.

<p style="margin-top:0.4em;margin-bottom:0.5em;line-height:19.1875px;font-family:sans-serif;">In 12w49a, enchanted books were added, and villagers could offer them.

<p style="margin-top:0.4em;margin-bottom:0.5em;line-height:19.1875px;font-family:sans-serif;">As of 13w04a, villagers spawned from renamed spawn eggs will show their name in the trading interface in place of "Villager".

[edit] Trivia

 * Right clicking on a villager pauses that villager's pathfinding.
 * Right-clicking on a villager right after a killing blow is dealt will result in the player trading with a dead villager. The trade goes through without any problems.
 * Charcoal can be sold as coal to blacksmiths and butchers.
 * You cannot trade with child villagers.
 * Trading is currently the only legitimate way to get Bottles O' Enchanting without creative mode.
 * Gold Ingots are used as a fallback offer; any time a villager randomly selects none of its offers, it chooses to buy gold ingots instead. This is why gold is offered so rarely as a trade, and also why it is the green villager's only item.
 * If you're not satisfied with the current trade offers, you can kill some of the villagers. The remaining villagers will start breeding again, resulting in possibly better offers. You can do this using environmental damage (fire, lava, TNT etc) as not to aggravate the village's Iron Golem.