Experience Orb

An Experience Orb is an entity similar to an item entity, an orb that fades between a green and yellow color. When collected by a player, that player is awarded experience points. Their behavior is slightly different from item entities: they move toward players from greater distances, and they cannot be held in an inventory nor stored in a container.

Behavior
Experience orbs drop in several situations: when a killed mob's corpse vanishes (unlike dropped resources which appear at death), when a player is killed, when animals breed, and when mining any ore that drops its mineral (that is, not iron, gold, or any use of Silk Touch). There are a couple of other cases where a player can be awarded experience, even though no orbs actually appear: Removing smelted products from a furnace, or catching fish with a fishing rod. Note that mobs will only drop experience if they were killed by the player (see below for details). Upon a player's death, they lose all experience points, but they themselves drop experience orbs, which they can collect after respawning and returning.

Experience Orbs vary in value, and most sources drop a random number of orbs with the total experience award divided among them. The general worth of an orb is reflected by its size, but the size does not increase much per point, and not at all past a certain extent.
 * Most passive mobs drop orbs totalling 1-3 experience points
 * Most hostile mobs drop of 5 (more if they spawned with armor or weapons).
 * Some mobs never drop experience: Baby mobs, villagers, golems, or bats.
 * A killed player drops 7 for each level they had, up to a maximum of 100 points.
 * A Wither drops 50 experience.
 * The Ender Dragon drops 11 huge orbs totalling 12,000 experience points.

When a player is within a 4 to 5 block range from an orb, the orb will be drawn toward the player and fly around them of its own accord, and will finally be consumed by the player, adding experience points to the player. Unlike resources, experience points are picked up gradually: no matter how many orbs are in range of the player, they will be added to the player's experience one at a time. 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 will disappear.

Dropping experience orbs
In general, mobs drop experience orbs if they were killed by the player, but some of the damage can be done by other means. Specifically, a mob will drop orbs if it was hit by a player or tamed wolf, within the last 3 seconds (60 ticks) before its death. This allows for monsters set on fire by the player (or attacked while burning in the sun), knocked off cliffs, or knocked into traps to still drop experience orbs. It also allows for "mob grinders" that reduce mobs to a few hit points, then let the player deal the killing blow. Arrows and thrown potions (or fire charges) count. Things that don't count as player attacks: Fall damage, suffocation, drowning, fire and lava, golems, anything from dispensers. A Ghast killed by its own rebounded fireball will drop orbs, but not if it was another Ghast's fireball. If a mob dies in or near lava or standing flame, then even if it was attacked by the player, some or all of the orbs may be destroyed.

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)

Trivia

 * 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 pulled towards a player are slowed by spider webs.
 * Experience orbs can be destroyed by fire, lava, explosions and cacti just like dropped items.
 * Experience orbs will despawn after five minutes, like dropped items.
 * Experience orbs can trigger pressure plates and tripwires.
 * When a player takes on many orbs at once they begin orbiting its head.
 * When a player picks up an experience orb from a Bottle o' Enchanting while riding on a minecart, the minecart will stop instantly (1.2.5 Creative).
 * By using an Inventory editor, you may create a "Spawn Experience Orb" egg, the ID being 383:2, although it will not actually spawn orbs.
 * The maximum experience that can be held by orbs of various sizes follows an irregular but roughly exponential progression: 1, 3, 7, 17, 37, 73, 149, 307, 617, 1237, 2477.  Thus the Enderdragon drops 1 orb of the largest size (2000 points), and 10 of the next-largest (1000 points), but most mobs will be limited to the two or three smallest sizes.