Talk:Trading

Ore


I don't think there is actually a new ore block, but I'm not sure. The image of that block (in the inventory) looks very similar to the smooth stone block, but there seems to be little specks as shown in the enlarged file image. - Asterick6 (talk) 06:07, 22 May 2012 (UTC)


 * That's what an ore block is. It's an overlay on a smoothstone image. Joe4429 06:08, 22 May 2012 (UTC)


 * (I know what an ore block is). Ok then this isn't a real image, and I don't think there is an actual ore block for the coin. - Asterick6 (talk) 06:13, 22 May 2012 (UTC)


 * It's in the top-right corner of the image. I created this out of what I can see. Joe4429 06:22, 22 May 2012 (UTC)


 * Ah I see it now. Interesting. - Asterick6 (talk) 06:36, 22 May 2012 (UTC)


 * Wait maybe this isn't a new ore, but just a new texture for the redstone ore. If there's a new gravel texture, then there might be a new redstone ore texture. We should just wait until more info is released... - Asterick6 (talk) 06:48, 22 May 2012 (UTC)
 * Here's an enhanced screenshot btw. - Asterick6 (talk) 21:43, 22 May 2012 (UTC)


 * I'm under the impression it's either a new texture, an ore he made just for testing, or something which may or may not be related to the trading system. In the case of testing, it'd drop coins just so he knows how the game drops them. I honestly wouldn't like an ore that drops acceptable coins or being able to personally craft coins which a Villager would accept. If money worked like that... Well. If it's crafted from some new gem, maybe it'd make sense, but you'd still have to craft it. The same picture shows 20 raw chickens gets a coin. MegaScience 09:52, 22 May 2012 (UTC)


 * Btw for the other comment about the trade file: I just copied that from the Villager article. You gotta remove that one too then. - Asterick6 (talk) 21:01, 22 May 2012 (UTC)

Chicken clarity
Although it says 1 coin for twenty chickens i bet it is similar to how if you put 64 wood blocks the output on the crafting table still says 4 planks, and you just press it 64 times or shift-click.It basically means you get 64 sets of four, so chicken would go 20 groups of 1. –Preceding unsigned comment was added by 24.139.40.70 (Talk) 10:57, 22 May 2012‎ (UTC). Please sign your posts with


 * I suspect similarly. Until we're sure of anything, we shouldn't put like "This equals that." or "This ends up as that." I might have added something similar, sorry if I did. Coins might stack to different amounts... Who knows? MegaScience 19:21, 22 May 2012 (UTC)


 * I just spawned around 100 villagers and tried to trade with them. First thing I realized is that most have only one Item in their Inventory, and only few had the possibility to trade 2. Then, I saw that ONE sold me Bottles o' Enchanting, meaning they are now avaliable in Survival Mode. Next thing to mention is that the Prices may differ (2 villagers both sold diamond Chestplates, one for 16, one for 17 Emeralds), and that the price system does not make much sense (4 diamonds for 1 Emerald WUT? never gonna do that). Librarians usually buy Paper/Books and sell Bookshelves.
 * --JayTie


 * You can even trade for chain armors (among all the iron and diamond tools and armors the game has) with blacksmiths. Also only the priests (purple clothes) can give you bottles o' enchanting. However, I noted that the prices aren't always the same from one villager to another.
 * --Pauolo 17:15, 24 May 2012 (UTC)

More Trade Get!
After trading, I noticed the villager had a purple swirly particle effect. The villager then had more options available for trading. So apparently, by trading with a particular villager, you can gain favor and open up more items to trade with that one villager with eight trades maximum. --108.76.103.35 16:44, 24 May 2012 (UTC)


 * That's right, but sometimes it requires more trading than only one to access to new options (maybe a bug, it seems this snapshot is quite laggy and has problems with map loading).
 * --Pauolo 17:01, 24 May 2012 (UTC)

Trading info on Villager article
I added trading info to the Villager article before I knew this article existed. I included a table which includes the quantities villagers buy/sell items and their prices, and I also included a chart of 55 test offers made by each villager class. I'm not sure how to merge that into this article, as some of the information here seems outdated or missing, but I don't think overwriting those parts of this article is necessarily a good idea. If anyone wants to make the merge when more is known about trading, feel free to do so. Just avoid throwing out data from either article :p --WolfieMario 21:09, 24 May 2012 (UTC)


 * I'm doing the trade data on this article. I'll go ahead and merge your findings with mine, and remove the table from the Villager page. (I'll leave the picture there for now; that's nifty.)


 * ...Oh, I haven't been paying attention to professions! I'll add the gold ingots to other professions, thanks. I'm merging by taking the min and max from each. I'm going to keep the table format here, but if someone wants to consolidate the formatting down the line, that'd be fine.

--Zeta0134 22:40, 24 May 2012 (UTC)


 * I'm going to bring the Trading text from Villager over to the Trading page, and replace it on the Villager page with a link. That should eliminate the redundancy and let us maintain it in one place.

--Zeta0134 22:49, 24 May 2012 (UTC)

EDIT: All done. Check to make sure I didn't butcher anything; it looks correct to me. --Zeta0134 22:53, 24 May 2012 (UTC)


 * You omitted some data (specifically, larger price ranges I found). I also re-added my observation chart, as there's currently nothing indicating how rare or common various offers are. --WolfieMario 23:13, 24 May 2012 (UTC)


 * Ayaaa, I updated my list in notepad++ but didn't transfer to the wiki. My bad, but looks like you fixed it. This page is certainly coming together. :D Most of the prices have stabilized for my testing; if anything, I think the only deviations will be in the blacksmith. --Zeta0134 23:25, 24 May 2012 (UTC)

pricing is a joke
i do hope this gets made more reasonable at official release, i mean damn, 4-5 diamonds/8-9 iron for a single Em and a compass costs 10 Em? sheeeeeeet. 96.61.162.71 04:21, 25 May 2012 (UTC)


 * You can also sell (renewable) wool at the rate of 20/1, and buy diamond gear for as little as 7 Em. There does not appear to be any kind of internal value to the items, I mean, a compass costs more than a diamond helmet.2.109.200.145 15:51, 25 May 2012 (UTC)Anonymus


 * I agree about diamonds, but 1 stack of logs gets you 3 Em if you cook them into charcoal so you can get lots of Ems cheaply. 78.150.199.100 13:54, 27 May 2012 (UTC)


 * They buy paper. One can make a huge automatic sugar cane farm for that. 4 stacks of sugar cane buy a diamond pickaxe, or a stack of cooked meat. 17,5 stacks of sugar cane buy a full diamond armor set. 2 inventories and a half buy Bottle o' Enchanting for lvl 50. --88.173.92.54 06:40, 29 May 2012 (UTC)

"villager" class villager
Can anyone find out if the villager (green robes, don't naturally spawn) has anything to sell, and if so, what?
 * It always only buys 8-9 gold ingots per emerald, and has no other offers. I put this information up before, but it seems it's been removed - it seems anything that does not normally occur in vanilla tends to get removed from this wiki :/ --WolfieMario 14:09, 25 May 2012 (UTC)

Will Obsidian be renewable?
You could buy Redstone and pour lava onto it, but is that a bug that might be fixed some time? 78.150.199.100 13:37, 27 May 2012 (UTC)


 * Obsidian is renewable. Since iron is renewable, so is a bucket, when 4 flowing lava meet they make still lava, and since water is renewable, pour water on the still lava to make obsidian. 71.46.222.254 14:15, 1 June 2012 (UTC)


 * The thing with the lava doesn't work anymore since a few versions. --☺ Sven R.I.P. Donna Summer 15:35, 1 June 2012 (UTC)


 * You could abuse nether portals for unlimited obsidian, also. OverPortal A to NetherPortal A.  NetherPortal A is autoconstructed.  NetherPortal B to OverPortal B.  OverPortal B is autoconstructed.  Harvest OverPortal B.  Return to nether through OverPortal A.  Return to Overworld through NetherPortal B.  OverPortal B is autoconstructed.  Harvest OverPortal B.  Repeat.  Since diamond picks are no longer limited, this method of harvesting obsidian is not limited.  --99.44.177.77 19:25, 4 June 2012 (UTC)

Will Lapis Lazuli be renewable?
Lapis Lazuli does not appear anywhere so I guess that is still non-renewable. 78.150.199.100 13:49, 27 May 2012 (UTC)

Price Information On all Items
Putting forward the idea to have item/block summary box (usually in the top right of a items page)have a new row added for example |cost = 1:8-10 (1 emerald for 8 to 10 of said item) So that when your on the items page you can see its costs 176.251.34.210 11:17, 28 May 2012 (UTC)

Villager Trading - Multipart Trades
The new trading system allows for multipart trades; 2 items go in (usually one of them Emerald), one item comes out. So far, I'm only seeing the PRIEST use this for applying enchantments. I'm presently building up a list of the options. So far, all enchantments that I've seen are level II of various things on tools and armor. --Zeta0134 14:35, 31 May 2012 (UTC)

Edit: There's the mentioned gravel trade with a blacksmith: 10 gravel and 1 Emerald for 2-3 Flint. No clue why anyone would actually do this of course. I'm also noticing a pattern with the enchantments; it seems to be a random set of enchantments, but the cost is always 2-4 emeralds. My guess is the level is always constant, maybe level 20? (That would make logical sense, requiring the player to get level 30 enchantments on their own.) More testing is needed, but I have to go to work now. Here's my list so far; if someone wants to continue and put this in the wiki, have at. This is bound to be very incomplete.

Enchants (priest) Iron Axe -> 4 -> Unbreaking II - Efficiency II Iron Axe -> 3 -> Unbreaking III Iron Pickaxe -> 2 -> Fortune I

Iron Chestplate -> 2-4 -> Fire Protection II Iron Chestplate -> 4 -> Projectile Protection III

Diamond Axe -> 4 -> Unbreaking II Diamond Pickaxe -> 2 -> Efficiency III

Diamond Chestplate -> 3 -> Protection II

Sells (priest) Eye of Emerald (1) -> 7 - 10

Buys (Librarian) Written Book -> 1

Sells (Librarian) Watch -> 10

Sells (Blacksmith) Arrow (5) -> 1

Converts (Blacksmith) Gravel (10) -> 1 -> Flint (2-3)

Buys (Farmer) Fish (9) -> 1 --Zeta0134 14:51, 31 May 2012 (UTC)


 * Are you sure that's what you got on a diamond axe? I made the same trade, and I got an axe with Unbreaking III and Efficiency III... Which would suggest that 1) These trades are just as random as actual enchanting, or 2) It's dependent on your level: I was in Creative mode, which automatically gives you maximum enchantability. ~GorgeousTaylor –Preceding unsigned comment was added by 68.108.243.114 (Talk) 17:01, 31 May 2012‎ (UTC). Please sign your posts with


 * The enchantments are random using level 5-19. (What that actually means is sort of up in the air, since enchantments were also scaled back to max level 30 with the update.) WolfieMario is doing disassembly of the code and filling in exact values, so the article should be completely accurate by the end of the day. To answer your question, yes the items will get different enchantments randomly, but it's not based on the player's level. --Zeta0134 17:24, 31 May 2012 (UTC)

Code analysis of 12w22a villager trading
Sorry, I didn't feel like making 275 trades again, so I instead decided to peek at the code :p For 12w22a, the villager class is. appears to be the method behind generating offers, and conveniently lists all offers. is the item class and  is the block class. Ctrl+Clicking in Eclipse makes it easy to find out what each offer is.

At the end of the method, it's revealed that the method is capable of adding multiple offers at once, but all calls to the method only request one new offer to generate. In addition, if no potential offers are generated, a default offer of buying gold ingots is generated - this is why the unused villager will only request gold ingots.

The method  called in the offer-generating method makes a new buy offer, while calls to   make new sell offers.

All buy offers are in exchange for 1 emerald. The quantity of item bought is derived from the contents of the  hashmap defined in the static section at the bottom. If no definition exists for an item in this hashmap, the quantity defaults to 1. If the first Integer in the pair of Integers of  (as defined in the static section) is greater than or equal to the second, then that is the amount which will be used for the stack quantity bought. Otherwise, the stack amount will range anywhere between the two integers (note that it can be as low as the minimum value, but only as high as the maximum value minus one, due to how  means coal is always bought in stacks of 16-23.

For sale offers, the stack value is determined in an identical manner, using the  hashmap (also defined in the static block at the bottom). However, the hashmap has negative values defined for some items. If this happens, the quantity is used (negated of course, so it is positive) for the item stack sold, and the cost in emeralds is 1. Otherwise, the quantity is the cost in emeralds and the item stack sold is 1. Therefore, it is impossible (with the current code) for a generated offer to have multiple emeralds in exchange for multiple items. Note that for negative values, the first Integer is actually the negation of the upper bound, and the second is the negation of one less than the lower bound.

For help understanding the  hashmap entries:   means flint and steel, in exchange for exactly 3 emeralds (remember that the second number is the upper bound plus one, so the actual range is [3,4), or [3,3], aka simply 3).   is bread, sold in stacks of 3-4 (consistent with observed values).

The probability of a given offer being a potential offer is equal to the float value passed to  or. However, the actual probability of getting this offer is less: first all potential offers are selected, and one offer will be selected at random out of these. Nevertheless, this is helpful at gauging the relative rarity of any given offer, so I will add information such as "rare" or "common" to the article itself.

Note that there are also special offers, not generated with the  or   methods.

The first unique offer is a farmer offer: at 50% chance, the following code will add a new potential offer:. This is 10 gravel and an emerald, in exchange for flint in quantities of 2-3.

The other special offers are by priests. Specifically, a 10% chance of each enchantment offer being a potential offer. Items which can be enchanted are iron and diamond swords, iron and diamond chestplates, iron and diamond hatchets, and iron and diamond pickaxes. The line  is repeated for each of these items (assuming that particular item will be a potential offer, which I already mentioned is a 10% chance). The request is the item in question and 2-4 emeralds, and the sold item is, to my understanding, the same item enchanted with a level of 5-19.

Here is the entire code of  (the villager class, containing all information on trade offers):

I'll be updating the article shortly. --WolfieMario 16:56, 31 May 2012 (UTC)


 * Neat! I updated the Enchantment area for Priests based on the code. I'm not sure if you should be posting the code here, but as the Bukkit team (employed by Mojang) regularly posts disassembled code in their public github, I'm sure it's not a problem.


 * I suppose the trickiest part will be matching up the items, as those garbage class names aren't helping us any. --Zeta0134 17:18, 31 May 2012 (UTC)


 * If I'm reading the code correctly, any time a villager's list is empty (which is rare, but possible) the game adds the offer for Gold Ingots to the list as a fallback. This explains why the green villager only ever offers that trade, and also why it rarely shows up for all the other professions. This also means that the Farmer can very rarely offer it; I'll update the list. --Zeta0134 17:36, 31 May 2012 (UTC)


 * Yes, you're reading it right. I find it amusing that the potential probability of a librarian offering to buy a written book is 1.3, or 130%. That means it can never default to gold ingot for a librarian, until Jeb fixes this. Kind of annoying since Written Book slightly throws off all other actual probabilities by always being in the draw for a new offer, but I suppose written book is a rather good deal, eh? :p --WolfieMario 20:26, 31 May 2012 (UTC)

Put it on pastebin for the sake of the page loading faster. Unrelated: how did you decompile/deobfuscate it? C ali nou - talk × contribs » 20:28, 31 May 2012 (UTC)
 * Oh, cool, I wasn't aware of that site. I didn't want to paste it inline, but I didn't know of any good alternatives.


 * Anyways, I used JAD (JAva Decompiler) to decompile all classes after extracting them from minecraft.jar (it lets you use the wildcard modifier, e.g. "*.class", to decompile all classes in a directory). I didn't deobfuscate it, as you can tell by the horrendously messy and difficult-to-read code. I did my best to understand it, however. See this post for how I figure out which classes to look in.


 * In this case, I noticed the text "Offers" in the NBT structure of a villager that has offers (using NBTedit on a schematic), and figured that must exist as a raw string somewhere in the code. Doing an Eclipse file search for that confirmed my notion - the only class with that string is EntityVillager, aka the class I had pasted here. --WolfieMario 20:44, 31 May 2012 (UTC)

Fun fact: there are 4 unused buy offers, found in the hashmap that indicates costs:

- 3 enderpearls for an emerald

- 34-47 seeds for an emerald (I would love this offer considering how many I have after using stacks of bonemeal in the dark to get loads of flowers :p)

- 30-37 melon seeds for an emerald

- 30-37 pumpkin seeds for an emerald

There are, of course, also the no-longer-used priest offers to buy eyes of ender and rotten flesh.

Finally, the following curiosity:

- the offer for arrows, but the greater value is the first slot. This means that the code will not bother generating a random number, and instead only offer 5 arrows. If the numbers are flipped, it's 6-19 arrows, and if the failsafe didn't exist it would have been 5-18 arrows (which isn't too far off). Hopefully Jeb fixes this one; it would be nice to buy arrows if you don't have a skeleton grinder. --WolfieMario 20:56, 31 May 2012 (UTC)

For those curious, the only change to trades brought by 12w23b is a correction to the librarian: He no longer has a 130% chance of potentially offering to buy written books; it's now the expected 30%. The arrow quirk, where the minimum value is greater than the maximum, is not fixed. --WolfieMario 23:56, 7 June 2012 (UTC)

Enchantments - Multiple of one Item?
Can someone verify whether a Priest will offer to enchant the same item multiple times? Does it check to see if the enchantments are the same, or would a new offer to enchant, say, an Iron Pickaxe with Unbreaking III replace the previous offer of an Iron Pickaxe with Efficiency II? --Zeta0134 00:04, 13 June 2012 (UTC)

Unlocking more offers
What is the most efficient way to unlock more trading offers in a survival game? Should I build a large nursing facility and pick vilagers out using a wagon until I get the right offer? --217.128.124.56 14:52, 4 June 2012 (UTC)
 * I'm not sure what you mean by a wagon, but it seems tedious to make a new villager for every offer you want. You'd have to search for that specific villager every time you want to make that trade, and that sound like more trouble to me than it's worth. Also, villagers breed until their population is 0.35x the number of "houses" (read: doors with ceilings). On a survival server I play on, I actually made a building with the 5 types of villagers each in a slot. Come 1.3, I'll just trade with them until all their offers are available. There's a 12-stack sugarcane farm nearby, which can be readily turned to paper and sold to librarians for roughly a half stack of emeralds each harvest. As long as you are trading the rightmost offer, new offers should get generated until all the common offers have been generated. If you're lucky, by the time only rare offers remain, the rightmost will be an offer to sell items (as emeralds are easy to farm from several materials). Fortunately, the worst deal, 5 diamonds for an emerald, belongs to the blacksmith, who's very likely to generate a new offer every time - thus you'd likely only need to spend 5 diamonds once. Remember, villagers can only generate a new offer after you've closed the trading interface. --WolfieMario 15:30, 4 June 2012 (UTC)

Giant octopods?!?!?!?
In part of the trivia section, it says: "This includes Written Books, with the requirement of obtaining Ink Sacs from Giant Octopods. It requires writing in a Book and Quill."

I'm thinking we should change that to say squids, as there is no evidence of any giant octopods in minecraft Jatsburgern 06:17, 5 June 2012 (UTC)


 * Well, I wrote this part, and remembered Marine Biology, the Prof. was Really sure that they were better-classified as "octopod(s)," so I actually looked it up. It seemed to support the Greek original of "octopus(es)," with "-pi" being a well-known False way to use it, as it was Not a Latin, original.  Meanwhile, "octopodes," and "octopods" were both other alternatives, used in the Latin naming scheme (which probably began what, like 150 years ago, more-or-less?).  But: my key point is that they Don't look anything-like "giant 'Squid'," since squid have 2 Really Long tentacle-like things, in addition to their regular, tentacles, whereas these MC giant Octopuses /-pods definitely Don't.  Oh, and to inform people reading about Trading that Written Books (I haven't seen this offer, yet, but I'm still letting Villagers breed in now-2 Villages near each other) are their best way to get Emeralds.  Yilante, June 5th, 2012. –Preceding unsigned comment was added by 108.228.150.192 (Talk) 03:10, 6 June 2012‎ (UTC). Please sign your posts with

I don't care if they are technicly octopods, if notch calls them flying purple space monkeys then thats what they are.--Diamond warrior 16:09, 8 June 2012 (UTC)

I happen to know the explanation.

The squids in Minecraft is indeed octopods. The reason for the mistake is that Minecraft was made by a Swede, and in Swedish, octopods and squids share the same name, bläckfisk. In fact, I thought, until recently, that octopi and squids were the same creature.

Difficulty in gauging the actual probability of an offer
To keep language simple/brief, I'm using the euphemism "hat" for the modified ArrayList which stores potential offers. As such, my simplification of the way an offer is generated is the following: Each offer in the code has a "probability value", which is the chance that offer is put in the hat. One offer is selected at random from this hat as the newly generated offer. For all intents and purposes, each offer in the hat has an equal chance of being drawn from the hat.

If somebody better versed in probability theory than me can help, that would be nice. Currently, I've realized that, due to how offers are generated, the only way I know to accurately calculate the actual chance of a given offer is rather unfeasible. Namely, it involves checking the probabilities of all possible combinations of other offers occurring, combined with the chance that a given item is the one to be picked.

For example, take the calculation involved for the percent chance a farmer will offer to buy wheat, assuming this farmer does not already offer to buy wheat:


 * 0.9 is the probability value for whether a wheat-buying offer is 'thrown in the hat.' We'll only check all cases when this has happened.


 * The probability values of all other offers a farmer provides (except the default gold offer, which lacks a probability value) are also needed.


 * The exact, actual probability of a farmer offering to buy wheat is 0.9 * n, where n represents the sum of the following combinations:


 * Each element to be summed into n is the probability that, assuming wheat is in the hat, wheat is drawn from the hat.


 * A given element of n may be 'the chance that wheat is drawn from the hat, assuming it is the only offer in the hat.' In this case, there is a 1.0 probability of the wheat offer being drawn, which we multiply by the probability of all other offers failing (0.5*0.5*0.6*0.1*0.7*0.7*0.7*0.7*0.7*0.7*0.5*0.5, or 0.00044118375).


 * Another element may be 'the chance that wheat is drawn from the hat, assuming the cooked fish offer is also in the hat.' In this case, there is an 0.5 probability of the wheat offer being drawn, and we multiply this by the probability of all other offers except fish failing (0.5*0.5*0.4*0.1*0.7*0.7*0.7*0.7*0.7*0.7*0.5*0.5, or 0.0002941225).

Why do I say this is unfeasible? All Possible combinations need to be accounted for in calculating n. Even ones such as 'the chance that wheat is drawn from the hat, assuming the cooked chicken, raw chicken, and shears offers are also in the hat' (which would be the 0.25 probability of wheat being drawn, multiplied by 0.5*0.5*0.6*0.1*0.7*0.7*0.7*0.3*0.7*0.3*0.5*0.5, or 0.00008103375). How many individual elements of n are there? For the farmer, 4096 combinations exist in which one offer is always used and the rest may or may not be used. That's 4096 calculations which you must sum together to obtain the value of n, which you then multiply by 0.9 just to figure out the chance a farmer will offer wheat (or, thankfully, any other offer with a probability value of 0.9).

That's 4096 calculations I'm sure nobody is going to make. For a given offer of the blacksmith, you would need to make 33,554,432 such calculations. Even with the librarian, the villager with the fewest offers, there are 64 distinct combinations to worry about.

If anybody with expertise in probability theory knows of a better way to get an accurate calculation of the probability of any given offer, please do help.

Either that, or if you're willing to write a program that can somehow produce an automated solution to this problem (as I imagine is more than possible, but I myself don't know enough about combinatorics to attempt it. Wolfram Mathematica may be a good shot, as it seems to already have the capability to list combinations from a set of elements).

I myself may take an empirical approach, and simply have a program simulate billions of offers generated, based on the actual game code, which could then provide decently accurate approximations of the actual probabilities. However, I won't get around to it right now; I may do it someday if nobody else can pose a better solution. --WolfieMario 02:32, 8 June 2012 (UTC)


 * Wow, that's even worse than the random number of weighted random items in stronghold etc. chests. Making a program to do all the work shouldn't be too hard, though. One approach would be to make a list of all possible 'hats' and their probabilities, stored in an array. Use the array index as a bitfield, with a 1 or 0 indicating if an offer is in the hat or not. For example, for the librarian, index 22 (binary 0010110) could indicate that written book, glass, and compass are in that hat. Once that's done, for each offer, iterate across the array checking for hats that include it (e.g.,  for the written book). Divide the chance of the hat by the number of items in it, and add that to a running total. When you reach the end of the list, record the total chance of that offer, and repeat for the next one. Does that make sense? I'm inclined to implement it in C for speed (blacksmith needs 26 iterations across a 67-million element array), but Java would also work. -- Orthotope 03:33, 8 June 2012 (UTC)


 * Blacksmith is being annoying, keeps giving me a segfault at about 62 million hats, but the rest worked nicely. I'll see if I can make a Java version that complains less tomorrow. Here's the data on the others; gold ingot chance is calculated as 1 - sum(other item chances) and came out the same as what's on the page now, so I'm fairly confident this is correct.


 * -- Orthotope 09:11, 8 June 2012 (UTC)


 * Thank you very much for this. Your method seems to make sense, and the results do as well (offers with equal probability values have the same chance of occurring, and the gold ingot check worked out as well). I really like how you used the array index to effectively store the hats. For extra confidence, maybe you could iterate over an imaginary villager I manually solved the probabilities of (when I was trying to discern whether my methodology was even a valid solution)?


 * {| class="wikitable"


 * Common || 0.8
 * Uncommon A || 0.2
 * Uncommon B || 0.2
 * Uncommon C || 0.2
 * Gold Ingot (default) || 10.24%
 * }
 * Uncommon C || 0.2
 * Gold Ingot (default) || 10.24%
 * }
 * Gold Ingot (default) || 10.24%
 * }


 * The proper solution is the following:


 * {| class="wikitable"


 * Common || 59.04%
 * Uncommon A || 10.24%
 * Uncommon B || 10.24%
 * Uncommon C || 10.24%
 * Gold Ingot (default) || 10.24%
 * }
 * Uncommon C || 10.24%
 * Gold Ingot (default) || 10.24%
 * }
 * Gold Ingot (default) || 10.24%
 * }


 * As you can tell, I kept my numbers simple so the calculations would be simple (common is .8*(1*(.8*.8*.8)+0.25*(.2*.2*.2)+.5*(3*(.2*.8*.8))+(1/3)*(3*(.2*.2*.8))), and uncommon are all .2*(1*(.2*.8*.8)+.25*(.8*.2*.2)+.5*(.8*.8*.8)+.5*(2*(.2*.2*.8))+(1/3)*(.2*.2*.2)+(1/3)*(2*(.8*.2*.8))) ). It surprised me that the uncommon items share the same chance with the default offer, but I wouldn't put too much thought into it.


 * Also, when you are iterating the blacksmith's results, remember there are two gold ingot offers (one being the default), and you can probably save a lot of computation time by only iterating once per each unique probability value (e.g. 0.7, 0.5, 0.3, 0.2, and 0.1). Thus far your program has calculated the same chance for all items of equal probability values (and, mathematically, this is how it should be), so it's safe to say 5 iterations of that 67-million-long array will get us exactly the same amount of information that, say, 26 would :p


 * Lastly, do you plan to add this data to the article, or should I? If you do, please add it in a new column (feel free to reword the probability column to something like "probability value" or anything else you feel is descriptive enough, and name the new column whatever you think makes sense). I think the actual probabilities, which should of course include the % sign so there is no confusion, should be to the right of the current probability values, because these are calculated values just as "price per unit ingredient" is. Either way, the original probability values should be kept, as they are easier to retrieve any time there is an update, and they are independent of each other (not to mention, they are needed so you can do what you just did :p).


 * Thanks very much again for your contribution! --WolfieMario 14:33, 8 June 2012 (UTC)


 * Test case works out the same as your results. There is a lot of duplication, especially with so many of the trades having the same probabilities; the trick is to figure out exactly how many duplicates there are. I'm working on a more efficient algorithm, as the performance loss with Java is rather substantial, and this will have to be recalculated every time the trade lists change. (C gives me about enough time to make a cup of tea before it runs out of memory. Java also runs out of memory (with a 1.5GB heap), but I could have sex with the S.O. (and take my time with it!) while waiting.)


 * I'll let you add it to the article, as you have a sense of how you want it to look. Knowing my aesthetic design skills, you'd probably reformat it anyway if I added it. ;) -- Orthotope 10:02, 9 June 2012 (UTC)


 * And done; blacksmith added to above table. Changed the program to add up hat probabilities as it goes, rather than storing them. Same number of iterations, so it takes a few minutes to process, but total memory used is under 1 MB. I can provide the source code, if anyone's interested. -- Orthotope 11:13, 9 June 2012 (UTC)


 * Thanks again, although I think you made a mistake on the blacksmith: at first, I was gonna chalk the default offer's inaccuracy off to rounding error (as I did for the Priest), but by the time I got to the end I see you left out Chainmail Boots. I've left the incorrect numbers (duplicating the value for Chainmail Boots even though this makes the total greater than 100%), as I figure it's better than nothing until you get around to redoing it :p --WolfieMario 23:52, 9 June 2012 (UTC)


 * Derp. Fixed. -- Orthotope 02:11, 10 June 2012 (UTC)

Unable to reproduce villager crashing bug
In the article, there is the following text:
 * When trading with a Villager, the game may glitch up when the Villager gives two offers that are the same in the fact of what you have to give the Villager. For instance, if you give a villager an Emerald, you will receive 5 arrows. The same villager has another offer: If you give him one Emerald, you will receive 7 steaks. By passing him an Emerald at any page, the game mechanics will glitch up and Minecraft will crash repeatedly (until you exterminate the Villager.)

I can't reproduce this glitch. It is *not* a glitch for a villager to offer more than one sale offer with the same quantity of emeralds - if it were, blacksmiths would be almost useless except in large quantities. For me, if a villager has multiple offers requesting the same item (i.e. multiple sale offers), on any page with offers not requesting that item, it defaults to the first offer which requests that item. Otherwise, on pages requesting that item, it properly displays the product to be bought. Not that hard to figure out really, and not a bug.

"The game mechanics will glitch up" is incredibly vague - all that tells us is something goes wrong and it's not a graphical glitch. Are we talking something like the glitch where you break a bed while sleeping, and suddenly you can walk into walls and act as though water isn't there? At any rate, I haven't had any crashes. Please update to the latest snapshot; it appears there was an update which corrected frequent crashes in survival.

Also, whatever your glitch is, surely "exterminating" the villager isn't the only way to fix it. Have you tried logging out, trading another villager, dying, sleeping, or going through a portal? I don't want to find all the fully-stocked villagers in my trading house in SMP killed because the wiki told someone it was the only solution to their problem. --WolfieMario 16:54, 10 June 2012 (UTC)

Gold Ingots Question
I have a priest buying gold ingots, selling eye of enders, and will enchant a diamond sword. I thought that the gold ingots meant that the NPC's list of offers was empty; so how did it generate the other 2 offers? -StTheo 16:15, 14 June 2012 (UTC)


 * As I understand it, when villagers add a new trade, they pick one at random as described on the page (see also WolfieMario's analysis above). If no offers are put on the list of possible new trades, gold ingots are the default option for the new trade. This is independent of which offers they already have. Is that any clearer? -- Orthotope 19:39, 14 June 2012 (UTC)

Durability per emerald
Imagine that you buy an Iron pickaxe for 10 emeralds. This equates to 25 uses for every emerald you paid with. If you buy a Diamond pickaxe for 15, you get 104 uses for every emerald. Thus, despite the Diamond tool being more expensive, it is the better buy. These stats should be available for every tool that can be bought.

Doesn't work
No matter what I do, I can't trade with anyone. I've tried in three different files, but nothing happens when I click on those useless villagers. I spent a LOT of time gathering a bunch of stuff to trade with these idiots just to find out it doesn't even work. What is going on? Constavros 00:02, 21 June 2012 (UTC)
 * What version/snapshot are you playing?It&#39;s ahme, AJC! 00:16, 21 June 2012 (UTC)

1.2.5, as far as I'm aware. - Constavros 07:16, 21 June 2012 (UTC)


 * Case closed, dear Watson. Trading is not implemented in version 1.2.5 --☺ Sven ? ! 13:15, 21 June 2012 (UTC)

Then what did I pay all that bloody cash for if I didn't even get the whole game? Constavros 18:35, 21 June 2012 (UTC)


 * Because 1.2.5 is the whole game. Snapshots are not for playing but for testing. If you really want to play with them you need to install them manually. --☺ Sven ? ! 18:43, 21 June 2012 (UTC)
 * Or you could just wait for 1.3 to come out. Snapshots are basically a preview of the upcoming update. --WolfieMario 20:20, 21 June 2012 (UTC)

Well, WHAT a surprise - it STILL doesn't work. Imagine that. I can at least get INTO the trading screen, but then nothing else happens. Constavros 19:11, 8 August 2012 (UTC)


 * So, you are putting the right amount of the right item into the left square but you cannot take another item out of the right square? --☺ Sven ? ! 14:00, 9 August 2012 (UTC)

Exactly. Nothing happens. I've been trying to to do this for two days, now, and those cheap hillbillies still won't trade even though I'm offering exactly what they want. Constavros 16:28, 9 August 2012 (UTC)

Are you using a 1.4 snapshot? If so, the villagers "dislike" you because either you hit them, kill one of their fellow villagers, or killed a iron golem. That may be the reasons why the Testificates are "refusing" to trade with you. {{User:Noobnathan}Noobnathan}} Noobnathan 21:35, 18 September 2012 (UTC)

12w25a changes
Examining the 12w25a code, there aren't any changes to offers, probabilities, or even quantities, so none of the numbers in the charts should be changed. However, a mechanic for the removal of offers is indeed in place - if the trading GUI is not open, a villager may get particles (the same as they do when they generate new offers) and an offer you have used will be deleted. I'm still looking for the code of this mechanic, and whether it is purely random or offers are given a "stock" value to determine how many times it may be used before expiring. --WolfieMario 15:52, 21 June 2012 (UTC)


 * Alright, I found the relevant code:

if(f.size > 1) {           int j = Y.nextInt(6) + Y.nextInt(6) + 3; if(j <= aod1.e) {               g = 20; au = aod1; }       }
 * If you trade an offer, the game increments the offer's "uses" and checks three things: if that offer's the last on the list, if there's more than one offer, and if the offer gives the villager emeralds. The first condition marks a villager to generate a new offer in 60 gameticks (at least, I think that's the unit used). The second is depicted above. The third increments the villager's "riches" property by the number of emeralds; as of yet the "riches" property has no use.


 * Of course, it's the second check that's important for offer removal. If the villager has more than one offer, a random number 3-13 is generated (the code is similar to lapis distribution: it favors values in the middle rather than the extremes). If this number is fewer than or equal to the number of times an offer has been used, it is marked to be removed 20 ticks after the interface is closed (and no, shift-clicking does not cheat this: uses are incremented properly whether you shift-click, click for each trade, or even open and close the GUI each time you trade).


 * It should be noted, however, that only one offer may be marked for removal at a time. If you make multiple trades before closing the gui, pushing multiple offers past the absolute maximum of 12 uses, only the last such offer will be removed. This can be used to cheat and keep offers, but you have to be careful and rely on the amount of offers remaining (one offer has to be sacrificed each time). Note that, even if an offer is far past its limit, it is not removed unless it is marked for removal, and it cannot be marked for removal if it is never traded.


 * Also, for adventure map makers, you may find it relevant that offers can theoretically have up to negative 12-billion or so uses if hacked, effectively ensuring the offer is never removed.


 * Anyways, I'll update the article to point out "3-15 uses" is not how it works. --WolfieMario 16:51, 21 June 2012 (UTC)


 * Well, I find this one funny:

aod1.f; if(aod1.a((aod)f.get(f.size - 1))) {           g = 60; as = true; } else if(f.size > 1) {           int j = Y.nextInt(6) + Y.nextInt(6) + 3; if(j <= aod1.e) {               g = 20; au = aod1; }       }        if(aod1.a.c == aet.bH.bT) at += aod1.a.a;
 * Jeb sneakily stuck an "else" before the check for marking item removal - notice it's on a separate line, but Java doesn't care :p


 * Anyways, that means that an offer is never removed if it's the last offer available. I had expected offers to vanish faster than they were appearing, and was surprised (and pleased) when that wasn't the case. I'll update the article. --WolfieMario 17:25, 21 June 2012 (UTC)


 * Interesting... so there's a trick involved here. With a single blacksmith, keep trading the right-most offer until he generates every offer on his list. Then, assuming that last offer isn't for Coal, trade coal with him until the coal offer disappears. Then trade his right-most offer again, until Coal appears as the LAST offer in an otherwise full list. Now you have a blacksmith with all offers unlocked; just make sure you bring a stack of coal, end your trading session with a coal sell, and he will never remove an offer.


 * Do I win? :D --Zeta0134 22:40, 21 June 2012 (UTC)


 * Sadly, no :(. Thanks to that "else", not only can the final offer not be removed - it can't bump another offer off the removal list either. I'm afraid there's no way to bump another offer off the removal list without some offer getting removed.


 * You can even try to intercept an offer's removal by closing and reopening the interface before 20 gameticks, and trade the last offer, but that only extends the offer's lifetime to 60 more gameticks - having someone constantly keep the interface open would prolong such an offer, but the only way to save it is to sacrifice some other offer in its stead.


 * Since all of these techniques to preserve offers are so troublesome (sacrificing other offers only works so long as there are other offers that can be sacrificed), I'd personally just prepare an inventory to buy as much of a rare offer as I want. If anything, this makes it possible to hoard items such as Bottles o' Enchanting on SMP, since even a player finding your source priest would have to go through the trouble of getting them to make the offer again. The same applies, say, if a priest ever offers me silk touch: I'd get as many of the requisite item as I can from a blacksmith, and enchant the whole inventory on the priest. I may sacrifice another offer to prolong that enchantment offer for one more inventory, but *always* preserving rare offers may just be more trouble than it's worth. --WolfieMario 00:18, 22 June 2012 (UTC)

Explanation for Flint Pricing
In the farmer's sell table, the "Price in Emeralds" for flint is listed as 10 gravel and 1 emerald. This seems to deviate from the heading, and certainly deviates from the pattern (none of the other entries under that heading list anything aside from emeralds.) If this is intentional there should be an explanation (probably a note 7) and likely a heading change. Cultist O 18:05, 25 July 2012 (UTC)

Paying a villager an emerald and some gravel to effectively break some different gravel for you really is stupid. But it's still far from the worst trade, as it can still be worth doing just to see what else you can get, unlike the compass trade. NightChime 06:18, 18 August 2012 (UTC)

Pics?
There should be pics for the different villagers next to "Priest" and "Blacksmith", etc.. This makes it easier to identify which villager will sell you what.

Bug?
So I tried out the villager trading and the butcher asks for 13 coal for 1 emerald. I instead gave him 13 charcoal and the trade still worked. Ansem911 19:13, 7 August 2012 (UTC)


 * Coal and charcoal are interchangeable for the purposes of villager trades. The same is true for different colors of wool. --WolfieMario 20:36, 11 August 2012 (UTC)

How to obtain a new train
In the version history, I saw "24.98.214.202" removed an explanation of this, saying "the sentence wasn't truthful so I removed it. I just tested it in my game and it doesn't work that way. sorry.". However, I cannot seem to replicate his/her claim; I can only obtain new trades by trading the last/rightmost offer. Is there another way, since this was removed?

Enchanting Limits
I think it's pretty complicated to look at the enchantment mechanics as the priests note asks, when someone could just do the math once for everyone. So, if my understanding that it works the same as regular enchanting (with a base enchantment level of 5-19) is correct, here it is, based on this.

Iron tools have enchantability of 14, armour 9, diamond stuff all has 10. Add one, to this, allong with our 5-19, and multiply it by 0.75, or 1.25 will give us our min/max: Looking here, we see that both iron and diamond include everything except:
 * Iron Tools: 15-43
 * Iron Armour: 11-36
 * Diamond Stuff: 12-38
 * Protection IV
 * Sharpness IV & V
 * Looting III
 * Efficiency IV & V
 * Fortune III

Assuming no one sees a flaw in my math, I think note 4 should read similar to: "...When creating the enchantment offer, the game uses a random enchantment level from 5-19. This means all Chestplate, sword and tool enchantments are possible except Protection IV, Sharpness IV & V, Looting III, Efficiency IV & V, and Fortune III. See Enchantment Mechanics for more detail." On second thought, I have a better proposal, join the discussion! Cultist O 12:11, 14 August 2012 (UTC)

Paying with more than one inventory of items
The article says "you may buy an offer as many times as you can afford with one inventory." While not wrong by conventional methods, you can potentially pay with several inventories worth of items by dropping items near the villager you're trying to trade with, then standing on the pile of goods while trading.

Of course, the more inventories you want to pay with, the greater need you have for a) trapping the villager, and b) chests near the villager. I've found the Ender Chest to be very helpful in transporting goods en masse; I've found it efficient enough that I tend not to use more than one large chest. NightChime 06:07, 18 August 2012 (UTC)

trading diamonds with the blacksmith
When you trade diamonds with a blacksmith, he seems to have a much further limit to his offers. That means that every time you trade the "last offer", you have a chance to get a new one ! That implies having more than 5 offers up to 22 (witnessed on both SMP and solo 1.3.2)

Recent changes
I've been anticipating a change to the trading mechanic for a little while now, and finally saw it mentioned in the |snapshot notes from 12w32a on August 9: "Villagers will not remove trades, but trading something else may be required to renew the old ones". I don't really understand how this is different than removal and would love some info. This article still has the old stuff about trade removal. I'm running the 1.4 Pre-Release but haven't been able to do any testing - can someone please explain what has changed, and update the article if necessary? 98.65.244.156 05:27, 24 October 2012 (UTC)

(What I've Noticed So Far in 1.4) You can no longer trade infinitely while within the trade GUI. That is to say, the trade limit is imposed during trades. The game will stop giving you your trade goods once you've traded the max number even without closing the GUI and opening it again. A red X appears over top the arrows in the trading GUI on the old trades to show when a trade can no longer be performed. You can remove these X's and trade for the old trades again after trading for the far-right/newest available trade at least once. Doing this reopens all locked trades so make sure to trade for everything you want as much as you can before unlocking them again. Villagers will close more than one trade option at once if you trade to the max on several different trade options without closing the GUI. This means you can't max one trade and then max another to keep the first trade open. All maxed trades will close. As for max number of trades allowed per trade option before it's closed I don't know yet. Also I don't know what the maximum number of trade options a villager can offer is now. I am experimenting with a butcher and he's not offering every possible butcher trade but he's stopped adding new trades at about 8 or so options. It could be that he needs to generate a new trade for something he's not offering yet in order to add it to the list and now that I have about half of his trades unlocked I'm just unlucky and not getting the others to show up yet. I'm glad that this means that (if I can keep them alive) villagers with good trades will become great commodities to have since you can "re-open" old trades if the last trade on their list is acceptable. If I get a blacksmith with diamond swords and armor and his final trade is something easy, I'll be thrilled. Villagers=Vending Machines. 97.119.38.109 23:13, 28 October 2012 (UTC)duocult


 * Unfortunately, even if there's more turnover, there's still no sense of even relative value. I've currently got a blacksmith who started by offering a diamond axe for 10E.  I eventually bought one, and he duly produced a second offer:  he'll buy 5 diamonds for 1 emerald.   The librarian is offering a single bookcase for 3, or 4 glass (in a desert) for one.  Meanwhile some of the farmers are offering 4 bread (with at least 6 wheat fields in sight!) or 2 flint.


 * Really, it's one thing to make sure the spread prevents triangle trades, but this is so ridiculous and erratic as to actually feel offensive. --Mental Mouse 12:21, 17 December 2012 (UTC)

Red cross on trading screen
What does a red cross through the arrow mean? PhilHibbs 16:18, 10 November 2012 (UTC)
 * It means the villager refuses to trade because he doesn't like you. --☺ Sven ? ! 16:25, 10 November 2012 (UTC)
 * That or he just wants you to trade for something else too #trigger_hurt(I 16:38, 10 November 2012 (UTC)

Overcostly???
4-5 emeralds for a hoe, WHAT THE.

124.120.178.241 11:45, 20 December 2012 (UTC)

I focus on trading wheat or coal for emeralds instead of mining. As soon as they offer any really bad offers, kill them off. My own preference is to turn them into ever so tasty Zombies. --Endy123 15:23, 20 December 2012 (UTC)

Enchanted Books
Any idea if the number of emeralds affects the book enchantment? --Kahless61 07:08, 22 December 2012 (UTC)


 * The cost is determined by the level of the enchantment, but which enchantment is not a factor. Here's the relevant bit of code from EntityVillager.class:

if (this.rand.nextFloat < this.func_82188_j(0.07F)) {  Enchantment var8 = Enchantment.enchantmentList[this.rand.nextInt(Enchantment.enchantmentList.length)]; int var10 = MathHelper.getRandomIntegerInRange(this.rand, var8.getMinLevel, var8.getMaxLevel); ItemStack var11 = Item.enchantedBook.func_92111_a(new EnchantmentData(var8, var10)); var6 = 2 + this.rand.nextInt(5 + var10 * 10) + 3 * var10; var2.add(new MerchantRecipe(new ItemStack(Item.book), new ItemStack(Item.emerald, var6), var11)); }


 * In short, the cost of an enchanted book is 2 + level * 3 + random(0, level * 10 + 5) emeralds. Level V enchantments can be extremely expensive. -- Orthotope 09:42, 22 December 2012 (UTC)


 * I just realized that you can only fit 64 emeralds (one stack) in the trading GUI, so some level V enchantments may be impossible to buy. Haven't tested it though. -- 08:57, 14 January 2013 (UTC)

When the villager is angry
I accidentally hit a villager and since then, the only offer he shows is crossed and I can't trade anything. I didn't find anything about this in the Wiki - it should be mentioned in this article. Plus is there any way to improve the relationship? 18:09, 8 January 2013 (UTC)
 * If you have previously traded with any other villagers, trading their last offers should improve your popularity. if this was your first contact with the village, you may be stuck.   See Village.  --Mental Mouse 23:37, 15 February 2013 (UTC)

Really strange prices in 1.4.7
It seems that price range has changed. Blacksmith in village I made offers me Diamond Boots for amazing price of only 2 Emeralds. Does anyone knows something about it? 77.89.73.134 11:15, 17 January 2013 (UTC)

Overly cheap?
Went to a priest and traded iron chestplate and 3 emeralds. Got Protection II and Thorns I. I'm not complaining.