No longer functions against the current versions of Minecraft but the code might be interesting.