Experience

Experience (EXP or XP for short) can be obtained by gathering experience orbs from mining, defeating mobs and players, breeding, trading, fishing, and using grindstones and furnaces. As is tradition, experience points accumulate into experience levels. However, unlike many games, experience levels do not directly increase the character's abilities. Instead, experience is used for enchanting and at anvils, to produce weapons, armor, and tools with various useful abilities.

Behavior
Most experience comes in the form of experience orbs, small green and yellow spheres that move toward the player and automatically get added to the player's total experience when collected. Experience orbs cannot be added to the player's inventory.

Gathering experience points from experience orbs 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 experience orbs worth 7 * current level experience points, up to a maximum of 100 points (enough to reach level 7), and all of the other experience vanishes. If the gamerule  is set to true, the experience is kept even if the player dies.

Experience can be gained from several different sources:
 * From killing monsters, which drop experience orbs along with any other items.
 * A mob does not drop experience unless it dies within five seconds (100 game ticks) of an attack registered as a player hit (including tamed wolves and TNT). This allows gaining experience from, say, knocking a monster off a cliff (fetching the orbs might be another question). You can also try to "claim" a burning monster by hitting or shooting it once—even if the blow doesn't kill it, if the fire does within 5 seconds, it drops XP.
 * Deaths of hostile Zombie Pigmen always register as kills by the player they are targeting, regardless of whether that player ever touched that Zombie Pigman.
 * Mobs killed by TNT activated by a player using flint and steel drop XP as usual; however, mobs killed by TNT that was activated by fire, redstone, or an explosion that wasn't player activated don't drop any experience.
 * Mobs drop a random number of orbs, and the orbs can have different values. However, the total value always remains within the values given below, regardless of difficulty setting.
 * Hostile mobs give more experience than passive ones. Baby animals, bats, golems, and villagers give no experience at all. The ender dragon gives orbs totaling 12,000 XP the first time a player kills it – over 200 times more than anything else in the game – and 500 XP the next times.
 * Some hostile mobs spawn with weapons, or can spawn with weapons and/or armor. These mobs give an extra 1–3 points (randomly) per piece of equipment that they spawned with. Equipment picked up after spawning doesn't count.
 * Mining (destroying) a spawner block gives 15–43 points of experience as orbs.
 * From mining any ore that drops a resource, rather than ore. The orbs are produced along with the mineral item(s). If a Silk Touch pickaxe is used to mine the ore block, the experience is not dropped, but the block can later be placed and mined normally to release the mineral and the experience.
 * The ore still produces orbs if destroyed by an explosion, whether or not it was caused by player activated TNT.
 * From smelting any of various items.
 * Smelting any ore yields some experience, but normally only iron and gold are worthwhile. For all other ores, mining them is better.
 * Moderate amounts are gained by smelting/cooking other materials: food, clay balls or blocks, cactus, wood logs, sand, or cobblestone, cactus giving the most.
 * The smelted material must be taken from the furnace through its GUI window. If the player uses a hopper to unload the furnace, it is possible to retrieve all experience produced by the furnace by smelting an extra item and taking it from the GUI. Dumping the contents by breaking the furnace destroys the experience.
 * From breeding animals, which produces orbs where the parents are, 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.
 * From trading with villagers.
 * A bottle o' enchanting releases orbs when broken.
 * From the command.
 * From disenchanting items in a grindstone.

Experience orbs
Experience orbs fade between a green and yellow color and float or glide toward the player up to a distance of 6 blocks, speeding up as they get nearer to the player. Experience orbs pulled toward a player are slowed by spider webs. Experience orbs can also be pulled around or away from the player by running water currents.

When collected, experience orbs make a Christmas bell-like sound for a split second. Unlike resources, experience points are picked up gradually: no matter how many orbs are in range of the player, they are added to the player's experience one at a time (around 10 orbs/second). In extreme cases, this can result in the player being followed by a swarm of orbs for many seconds. If an experience orb isn't collected within 5 minutes of its appearance, it disappears.

Experience orbs vary in value, but naturally spawned orbs always have an integer value of 1–11, 17, 37, 73, 149, 307, 617, 1237, or theoretically 2477 (although currently, no orbs with this value can spawn). Fishing, breeding, and trading drop a single orb with a random value in the appropriate range. Breaking blocks, killing mobs and players, smelting items, and bottles o' enchanting calculate their total experience amount and then split it into values of 1, 3, 7, 17, 37, 73, 149, 307, 617, 1237, and 2477. Higher values are chosen first, so, for example, a total value of 1000 would be dropped as orbs with values 617, 307, 73, and three 1s. Note that while the first Ender Dragon in a world drops 12,000 experience, it is dropped in 10 waves of 1000 and one of 2000, so no orbs of value 2477 are dropped.

The general worth of an orb is reflected by its size, with eleven possible sizes corresponding to values 1–2, 3–6, 7–16, 17–36, 37–72, 73–148, 149–306, 307–616, 617–1236, 1237–2476, and 2477 and up.

Like items, experience orbs float when on water. Experience orbs can be destroyed by fire, lava, explosions and cacti, and can trigger pressure plates and tripwires. Although mob drops spawn the instant the final blow is dealt to the mob, experience orbs do not until the mob entity disappears and the smoke appears. Experience orbs can also stop minecarts.

Experience amounts by source

 * 16
 * Player dings
 * 16
 * }
 * 16
 * Player dings
 * 16
 * }
 * 16
 * }
 * 16
 * }
 * 16
 * }
 * }

ID
Java Edition:

Bedrock Edition:

Entity data
Experience orbs have entity data associated with them that contain various properties of the entity.

History
In an image of the new lighting system, a small yellow (the orb was yellow due to a warm light from a torch) spherical shape can be seen on the left side of the screen, but a day after the photo was published Notch claimed it had an error and posted a new one, this time, without a yellow sphere. In a later tweet, Notch showed a picture of a Beta 1.7 change-list (back then the Adventure Update was supposed to be in Beta 1.7). Although it was completely blurred out and was, at first, thought of as a joke, but then Notch stated that one of the pictures with the new lighting system and the change list had a secret in them, and people all around the web started speculating.

One place that people discussed it was on the Minecraft forums, where it was discovered that the tabs at the top of the change list that were partly covered, could be decoded based on the 2 pixel tall pattern available in the image.

After a user named "tmcaffeine" successfully decoded it, the tabs read: ExperienceOrb.java, changelist.txt, Level.java, Tile.java, HugeMushroomTile.java, HugeMushroomFeature.java, RandomLevelSource(cut)



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.) Afterward, 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 39). 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 cost is equivalent of 165 "common" mobs, less than 1/5 the old price.

Trivia

 * If a player kills a mob by firing potions out of a dispenser, no experience is dropped.
 * Using experience on enchanting or repairing does not decrease the score which is shown upon death.
 * If the player gains too many experience points, such as 1 trillion, the experience bar and level counter completely disappear from the HUD. This appears to occur around level 32,767 or 215&minus;1, the largest value representable by a 16-bit signed integer.
 * The maximum XP that can be gained from the command is 2,147,483,647 levels or 231&minus;1, the largest value representable by a 32-bit signed integer and by Java's int type.
 * The maximum level is 238,609,311 before the experience bar disappears altogether.
 * Every 5 levels, a special XP sound plays. The sound plays each time the player reaches a multiple of 5 levels.
 * Before Beta 1.9 Prerelease 2, the score read &e0.
 * This was caused by an error in which the game renders color text. §e0 would render the text as 0, but shaded bright yellow. From Indev 0.31 (the version in which the precursor to experience, a score system, was removed after Survival Test) to this version, a bug arose where it would display &e0 instead, a common error when formatting color text in Minecraft (except on custom servers with the plugin to override this).
 * Despite being widely dropped by mobs and blocks and being obtainable from fishing, experience cannot be configured using loot tables.