if(count > 0 && !worldObj.isRemote) {
for(EntityItem entity : items) {
ItemStack item = entity.getEntityItem();
if(item.getItem() == Items.enchanted_book) {
NBTTagList enchants = Items.enchanted_book.func_92110_g(item);
if(enchants != null && enchants.tagCount() > 0) {
NBTTagCompound enchant = enchants.getCompoundTagAt(0);
short enchantId = enchant.getShort("id");
short enchantLvl = enchant.getShort("lvl");
if(!hasEnchantAlready(enchantId) && isEnchantmentValid(enchantId)) {
this.enchants.add(new EnchantmentData(enchantId, enchantLvl));