The purple gem was capable of fulfilling the subconscious wishes of the person who held it. Only wishes that were thought up in the person's head would be granted. Wishes spoken out loud, however, would not.
And as Billy headed back towards his friends, he wished for something in his head, not knowing that it would be granted by the purple gem he had found.