public static ItemStack addPhoto(ItemStack stack, PhotoInformation photo) {
    if (stack == null || !(stack.getItem() instanceof ItemPhotoStorage)) {
      return stack;
    }

    CameraCraftItem.createStackTagCompound(stack);

    NBTTagList photos = stack.stackTagCompound.getTagList("photos");
    photos.appendTag(photo.createNBT());
    stack.stackTagCompound.setTag("photos", photos);
    return stack;
  }
  public static PhotoInformation getPhotoWithIndex(ItemStack stack, int index) {
    if (stack == null || !(stack.getItem() instanceof ItemPhotoStorage)) {
      return null;
    }

    CameraCraftItem.createStackTagCompound(stack);
    NBTTagList photos = stack.stackTagCompound.getTagList("photos");
    if (index < photos.tagCount()) {
      return PhotoInformation.createFromNBT((NBTTagCompound) photos.tagAt(index));
    } else {
      return null;
    }
  }
  public static PhotoInformation getPhotoWithID(ItemStack stack, String photoID) {
    if (stack == null || !(stack.getItem() instanceof ItemPhotoStorage)) {
      return null;
    }

    CameraCraftItem.createStackTagCompound(stack);
    NBTTagList photos = stack.stackTagCompound.getTagList("photos");
    for (int i = 0; i < photos.tagCount(); i++) {
      PhotoInformation info = PhotoInformation.createFromNBT(((NBTTagCompound) photos.tagAt(i)));
      if (info.getPhotoId().equals(photoID)) {
        return info;
      }
    }
    return null;
  }
  public static PhotoInformation[] getPhotosFromItemStack(ItemStack stack) {
    if (stack == null || !(stack.getItem() instanceof ItemPhotoStorage)) {
      return null;
    }

    CameraCraftItem.createStackTagCompound(stack);

    NBTTagList photos = stack.stackTagCompound.getTagList("photos");
    PhotoInformation[] infos = new PhotoInformation[photos.tagCount()];
    for (int i = 0; i < infos.length; i++) {
      infos[i] = PhotoInformation.createFromNBT((NBTTagCompound) photos.tagAt(i));
    }

    return infos;
  }
  public static ItemStack deletePhoto(ItemStack stack, int photoIndex) {
    if (stack == null || !(stack.getItem() instanceof ItemPhotoStorage)) {
      return stack;
    }

    CameraCraftItem.createStackTagCompound(stack);

    NBTTagList photos = stack.stackTagCompound.getTagList("photos");
    NBTTagList newPhotos = new NBTTagList();
    for (int i = 0; i < photos.tagCount(); i++) {
      if (i != photoIndex) {
        newPhotos.appendTag(photos.tagAt(i));
      }
    }
    stack.stackTagCompound.setTag("photos", newPhotos);
    return stack;
  }
  public static ItemStack deletePhoto(ItemStack stack, String photoID) {
    if (stack == null || !(stack.getItem() instanceof ItemPhotoStorage)) {
      return stack;
    }

    CameraCraftItem.createStackTagCompound(stack);

    NBTTagList photos = stack.stackTagCompound.getTagList("photos");
    NBTTagList newPhotos = new NBTTagList();
    for (int i = 0; i < photos.tagCount(); i++) {
      if (!PhotoInformation.createFromNBT((NBTTagCompound) photos.tagAt(i))
          .getPhotoId()
          .equals(photoID)) {
        newPhotos.appendTag(photos.tagAt(i));
      }
    }
    stack.stackTagCompound.setTag("photos", newPhotos);
    return stack;
  }
  public static ItemStack renamePhoto(ItemStack stack, int index, String newName) {
    if (stack == null || !(stack.getItem() instanceof ItemPhotoStorage)) {
      return stack;
    }

    CameraCraftItem.createStackTagCompound(stack);

    NBTTagList photos = stack.stackTagCompound.getTagList("photos");
    NBTTagList newPhotos = new NBTTagList();
    for (int i = 0; i < photos.tagCount(); i++) {
      if (i != index) {
        newPhotos.appendTag(photos.tagAt(i));
      } else {
        newPhotos.appendTag(
            PhotoInformation.createFromNBT((NBTTagCompound) photos.tagAt(i))
                .setName(newName)
                .createNBT());
      }
    }
    stack.stackTagCompound.setTag("photos", newPhotos);
    return stack;
  }