Experience



Experience (or XP for short) can be obtained by gathering Experience Orbs from mining, defeated mobs and players, breeding, fishing, and using Furnaces. Experience is used for Enchanting and Anvils.

Behavior
Most experience comes in the form of Experience Orbs, special items which cannot be placed in inventory or a container, but will automatically be added to the player's total when collected. Experience orbs will "float" or glide toward the player if they are 2-3 blocks away.

Gathering experience points increases the player's experience level by gradually filling a bar on the bottom of the screen until a new level is achieved when the bar is full. When the player dies, they drop 7 times their level as experience orbs, up to a maximum of 100 points (enough to reach level 5). All the other experience vanishes.

Experience can be gained from several different sources:
 * As traditional, from killing monsters, which drop Experience Orbs along with any other items.
 * A mob will not drop experience unless it dies within three seconds (60 game ticks) of being damaged by a player. This allows gaining experience from, say, knocking a monster off a cliff, or by setting a sufficiently-damaged mob on fire.
 * Mobs will drop a random number of orbs, and the orbs can have different values. However, the total value will always remain within the values given below, regardless of difficulty setting.
 * Baby animals, bats, golems, and villagers give no experience, and hostile mobs give more than passive ones. The Enderdragon gives orbs totalling an 12,000 XP, over 200 times more than anything else in the game.
 * Mining (destroying) a spawner block gives a hefty amount of experience as orbs.
 * From mining those ores which drop as items: coal, lapis lazuli, redstone, emeralds, diamonds, and nether quartz.  The orbs are produced along with the mineral item(s).
 * From smelting any of various items.
 * Smelting the high-value ores yields the most experience, but for any ore except iron or gold, smelting gives far less experience than mining the block.
 * Lesser amounts are gained by cooking food, baking clay balls or blocks, and smelting cactus, low-value ores, wood logs, sand, or cobblestone.
 * The experience given from smelting does not appear as orbs, but is granted immediately to the player who removes the product from the furnace.
 * The smelted material must be taken from the furnace through its GUI window. Using a hopper to unload the furnace forfeits the experience, as does breaking a furnace with smelted material.
 * From breeding animals, which produces orbs along with the baby animal. Breaking eggs does not give experience.
 * From fishing. The experience is awarded immediately upon reeling in the fish, even if the fish itself is not picked up.
 * A Bottle o' Enchanting releases orbs when broken.

Experience Amounts by source.


Leveling Up
Since Snapshot 12w23a, the way levels are gained has changed. The first 16 levels are linear (17 XP points per level), while level 17+ require more points per level compared to the prior level. The exact algorithm for experience required to get from your current level to the next is as follows (as recovered from the 1.5.1 source code): currentLevel >= 30 ? 62 + (currentLevel - 30) * 7 : (currentLevel >= 15 ? 17 + (currentLevel - 15) * 3 : 17.

In other words, if your current level is greater than or equal to 30, then you need [(7 * currentLevel) - 148] experience to gain another level. If your current level is between (inclusive) 16 to 29, you need [(3 * currentLevel) - 28)] experience to gain another level. If your level is 15 or below then you need a static (17) experience to gain another level.

The xp (y) required for the level (x) can be calculated as follows:

for 0≤x≤16: y=17x

for 15≤x≤31: y=1.5x²-29.5x+360

for x≥30: y=3.5x²-151.5x+2220

A calculator is available using the chart data below to detail for the user how much additional experience they need to obtain to reach a particular level. 

 XP required,XP diff 17,17 34,17 51,17 68,17 85,17 102,17 119,17 136,17 153,17 170,17 187,17 204,17 221,17 238,17 255,17 272,17 292,20 315,23 341,26 370,29 402,32 437,35 475,38 516,41 560,44 607,47 657,50 710,53 766,56 825,59 887,62 956,69 1032,76 1115,83 1205,90 1302,97 1406,104 1517,111 1635,118 1760,125  

Note that when enchanting, the experience levels used will be subtracted from your current level, not your current XP total. This has important implications for leveling above 30—the levels gained will have a high XP cost, but this will not be preserved. For example, if you are enchanting anything at level 30: if you earn enough experience to get to level 31, then enchant, you will be left at level 1. If you had enchanted first, and collected the same amount of experience afterwards, you would have reached level 5.

Pre-Snapshot 12w23a
The experience level costs were heavily revised in snapshot 12w22a and 12w23a. Before these, reaching level 50 (the maximum usable on a single enchantment) required 4625 experience, corresponding to defeating 925 hostile mobs (assuming the "common" ones.) Afterwards, considerably less experience is needed to get into higher levels (The amount which would formerly get the player to level 30 now gets them to level 93). Higher levels cost more experience than lower ones, but the levels are still easier to get than in 1.2.5. Now level 30 is the maximum for enchantments, and that costs the equivalent of 165 "common" mobs, less than half the number under the old system.

Trivia

 * Experience orbs will drop from a mob if it dies within 5 seconds of being hit by a player. This means you can use fall damage by knocking mobs off a cliff.
 * Signs cannot be seen through experience orbs.
 * Using enchantments does not decrease your score (which is shown on death).
 * The announcement of the changes in snapshot 12w23a incorrectly stated "enchantment levels are slightly exponential again"; in fact, they are quadratic at higher levels.
 * If you gain too many experience points (such as a trillion through server commands), the experience bar will disappear altogether as well as your level on your HUD. This appears to occur around level 32,767 (the largest value representable as a 16-bit signed integer).
 * The maximum XP that you can earn from a Command Block is 1,999,999,999
 * The maximum experience level is 24791
 * The highest level you can gain with /xp without overflowing is 1241258, which results in 2,147,483,647 exp, which is the highest possible integer in Java

Useful Numbers

 * Killing one large slime and all the slimes that split from it will yield from 12 to 28 experience, with an average of 19.
 * The maximum that can be used on a single enchantment is 30 levels, while the anvil will accept jobs up to level 39 (in creative mode the anvil limit is lifted).
 * Level 22 is about halfway to level 30; level 31 is about halfway to level 40.
 * One can determine how much experience has been collected to reach a level using the equations:
 * Total Experience = 17[Level] (at levels 0-15)
 * 1.5[Level]2 - 29.5[Level] + 360 (at levels 16-30)
 * 3.5[Level]2 - 151.5[Level] + 2220 (at level 31+)
 * This equation does not include any experience that is currently filling the experience bar.


 * Additionally, the amount of experience required to advance to the next level can be calculated using the equations:
 * Experience Required = 17 (at levels 0-14)
 * 3[Current Level] -28 (at levels 15-29)
 * 7[Current Level] - 148 (at level 30+)


 * Killing the Enderdragon will now give approximately 78 XP Levels (105 before 12w22a). The Enderdragon actually drops 10 orbs worth 1,000 experience points, and another worth 2,000.  Taken separately, the smaller orbs could take a player from zero to level 32, while the big orb would take a player from zero to level 41.