Example #1
0
  public static final void increaseStackQuantity(ItemStack itemStack, int quantity) {
    if (itemStack.getItem() instanceof IFood) {
      IFood food = (IFood) itemStack.getItem();
      float newQuantity = food.getFoodWeight(itemStack) + quantity;

      Food.setWeight(itemStack, newQuantity);
    } else itemStack.stackSize += quantity;
  }
Example #2
0
  public static final int getItemStackQuantity(ItemStack itemStack, boolean removeDecay) {
    if (itemStack.getItem() instanceof IFood) {
      IFood food = (IFood) itemStack.getItem();
      float foodDecay = removeDecay ? Math.max(food.getFoodDecay(itemStack), 0) : 0;
      int quantity = (int) (food.getFoodWeight(itemStack) - foodDecay);

      return quantity > 0 ? quantity : 0;
    }

    return itemStack.stackSize;
  }