Minecraft wiki entry for Enchanting_mechanics, associated text: where b is the number of nearby bookshelves (maximum of 15) and x..y generates a uniformly distributed random integer between x and y, inclusive. This is then modified according to the slot position: