public ShapedCraftingRecipe(Item nominalOutput,RecipeFunction recipeFunction,String format,boolean mirrored,ItemIngredient... ingredients){
  this.nominalOutput=nominalOutput;
  String[] formatLines=format.split("\\-");
  int numIngredients=0;
  int width=0;
  for (  String formatLine : formatLines) {
    width=Math.max(width,formatLine.length());
    for (    char c : formatLine.toCharArray()) {
      if (c == ' ') {
        continue;
      }
 else       if (c >= 'A' && c <= 'Z') {
        numIngredients++;
      }
 else {
        throw new IllegalArgumentException("Invalid character in format string " + format + ": "+ c);
      }
    }
  }
  this.width=width;
  this.height=formatLines.length;
  this.posx=new int[numIngredients];
  this.posy=new int[numIngredients];
  this.ingredients=new ItemIngredient[numIngredients];
  this.mirrored=mirrored;
  int ingredientIndex=0;
  for (int y=0; y < this.height; y++) {
    String formatLine=formatLines[y];
    for (int x=0; x < formatLine.length(); x++) {
      char c=formatLine.charAt(x);
      if (c == ' ') {
        continue;
      }
      this.posx[ingredientIndex]=x;
      this.posy[ingredientIndex]=y;
      this.ingredients[ingredientIndex]=ingredients[c - 'A'];
      ingredientIndex++;
    }
  }
  this.recipeFunction=recipeFunction;
  this.lastIngredientIndexOnFirstLine=getLastIngredientIndexOnFirstLine();
}

public ShapedCraftingRecipe ( Item nominalOutput , RecipeFunction recipeFunction , String format , boolean mirrored , ItemIngredient ... ingredients ) { this . nominalOutput = nominalOutput ; String [ ] formatLines = format . split ( "\\-" ) ; int numIngredients = 0 ; int width = 0 ; for ( String formatLine : formatLines ) { width = Math . max ( width , formatLine . length ( ) ) ; for ( char c : formatLine . toCharArray ( ) ) { if ( c == ' ' ) { continue ; } else if ( c >= 'A' && c <= 'Z' ) { numIngredients ++ ; } else { throw new IllegalArgumentException ( "Invalid character in format string " + format + ": " + c ) ; } } } this . width = width ; this . height = formatLines . length ; this . posx = new int [ numIngredients ] ; this . posy = new int [ numIngredients ] ; this . ingredients = new ItemIngredient [ numIngredients ] ; this . mirrored = mirrored ; int ingredientIndex = 0 ; for ( int y = 0 ; y < this . height ; y ++ ) { String formatLine = formatLines [ y ] ; for ( int x = 0 ; x < formatLine . length ( ) ; x ++ ) { char c = formatLine . charAt ( x ) ; if ( c == ' ' ) { continue ; } this . posx [ ingredientIndex ] = x ; this . posy [ ingredientIndex ] = y ; this . ingredients [ ingredientIndex ] = ingredients [ c - 'A' ] ; ingredientIndex ++ ; } } this . recipeFunction = recipeFunction ; this . lastIngredientIndexOnFirstLine = getLastIngredientIndexOnFirstLine ( ) ; }
defines an advanced crafting recipe , using a format string .
