public ItemStack[] getRemainingItems(InventoryCrafting inv) { ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()]; for (int i = 0; i < aitemstack.length; ++i) { ItemStack itemstack = inv.getStackInSlot(i); if (itemstack != null && itemstack.getItem() instanceof ItemEditableBook) { aitemstack[i] = itemstack; break; } } return aitemstack; }
@Override public ItemStack getCraftingResult(InventoryCrafting crafting) { for(int slot = 0; slot < crafting.getSizeInventory(); slot++) { if(crafting.getStackInSlot(slot) != null){ if (crafting.getStackInSlot(slot).getItem().equals(Items.written_book)) { ItemStack stack = crafting.getStackInSlot(slot); ItemStack output = getRecipeOutput().copy(); if (ItemEditableBook.validBookTagContents(stack.getTagCompound())) { NBTTagList text = stack.getTagCompound().getTagList("pages", 8); output.setTagInfo("pages", text); return output; } } } } return getRecipeOutput(); }
/** * Returns an Item that is the result of this recipe */ public ItemStack getCraftingResult(InventoryCrafting inv) { int i = 0; ItemStack itemstack = null; for (int j = 0; j < inv.getSizeInventory(); ++j) { ItemStack itemstack1 = inv.getStackInSlot(j); if (itemstack1 != null) { if (itemstack1.getItem() == Items.written_book) { if (itemstack != null) { return null; } itemstack = itemstack1; } else { if (itemstack1.getItem() != Items.writable_book) { return null; } ++i; } } } if (itemstack != null && i >= 1 && ItemEditableBook.getGeneration(itemstack) < 2) { ItemStack itemstack2 = new ItemStack(Items.written_book, i); itemstack2.setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); itemstack2.getTagCompound().setInteger("generation", ItemEditableBook.getGeneration(itemstack) + 1); if (itemstack.hasDisplayName()) { itemstack2.setStackDisplayName(itemstack.getDisplayName()); } return itemstack2; } else { return null; } }