예제 #1
0
  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;
  }
예제 #2
0
  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;
  }
예제 #3
0
  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;
    }
  }
예제 #4
0
  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;
  }
예제 #5
0
  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;
  }
예제 #6
0
  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;
  }