/**
  * Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't
  * full, etc.
  */
 private boolean canSmelt() {
   if (this.furnaceItemStacks[0] == null) {
     return false;
   } else {
     ItemStack itemstack = RefineryRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);
     if (itemstack == null) return false;
     if (this.furnaceItemStacks[2] == null) return true;
     if (!this.furnaceItemStacks[2].isItemEqual(itemstack)) return false;
     int result = furnaceItemStacks[2].stackSize + itemstack.stackSize;
     return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize());
   }
 }
  /**
   * Turn one item from the furnace source stack into the appropriate smelted item in the furnace
   * result stack
   */
  public void smeltItem() {
    if (this.canSmelt()) {
      ItemStack itemstack = RefineryRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);

      if (this.furnaceItemStacks[2] == null) {
        this.furnaceItemStacks[2] = itemstack.copy();
      } else if (this.furnaceItemStacks[2].isItemEqual(itemstack)) {
        furnaceItemStacks[2].stackSize += itemstack.stackSize;
      }

      --this.furnaceItemStacks[0].stackSize;

      if (this.furnaceItemStacks[0].stackSize <= 0) {
        this.furnaceItemStacks[0] = null;
      }
    }
  }