22
33import  mezz .jei .api .ingredients .IIngredientHelper ;
44import  mezz .jei .api .ingredients .IIngredientType ;
5- import  mezz .jei .api .ingredients .ITypedIngredient ;
65import  mezz .jei .api .ingredients .subtypes .UidContext ;
76import  mezz .jei .api .recipe .RecipeType ;
87import  mezz .jei .api .runtime .IIngredientManager ;
2625import  org .apache .logging .log4j .Logger ;
2726import  org .jetbrains .annotations .Nullable ;
2827
28+ import  java .util .ArrayList ;
2929import  java .util .Collection ;
30+ import  java .util .List ;
3031
3132public  final  class  ErrorUtil  {
3233	private  static  final  Logger  LOGGER  = LogManager .getLogger ();
@@ -169,10 +170,6 @@ public static <T> void validateRecipes(RecipeType<T> recipeType, Iterable<? exte
169170		}
170171	}
171172
172- 	public  static  <T > CrashReport  createIngredientCrashReport (Throwable  throwable , String  title , IIngredientManager  ingredientManager , ITypedIngredient <T > typedIngredient ) {
173- 		return  createIngredientCrashReport (throwable , title , ingredientManager , typedIngredient .getType (), typedIngredient .getIngredient ());
174- 	}
175- 
176173	public  static  <T > CrashReport  createIngredientCrashReport (Throwable  throwable , String  title , IIngredientManager  ingredientManager , IIngredientType <T > ingredientType , T  ingredient ) {
177174		CrashReport  crashReport  = CrashReport .forThrowable (throwable , title );
178175		CrashReportCategory  category  = crashReport .addCategory ("Ingredient" );
@@ -183,7 +180,23 @@ public static <T> CrashReport createIngredientCrashReport(Throwable throwable, S
183180	public  static  <T > void  logIngredientCrash (Throwable  throwable , String  title , IIngredientManager  ingredientManager , IIngredientType <T > ingredientType , T  ingredient ) {
184181		CrashReportCategory  category  = new  CrashReportCategory ("Ingredient" );
185182		setIngredientCategoryDetails (category , ingredientType , ingredient , ingredientManager );
186- 		LOGGER .error (crashReportToString (throwable , title , category ));
183+ 		LOGGER .error (crashReportToString (throwable , title , List .of (category )));
184+ 	}
185+ 
186+ 	public  static  <T > void  logIngredientCrash (
187+ 		Throwable  throwable ,
188+ 		String  title ,
189+ 		IIngredientManager  ingredientManager ,
190+ 		IIngredientType <T > ingredientType ,
191+ 		T  ingredient ,
192+ 		CrashReportCategory ... extraCategories 
193+ 	) {
194+ 		CrashReportCategory  category  = new  CrashReportCategory ("Ingredient" );
195+ 		setIngredientCategoryDetails (category , ingredientType , ingredient , ingredientManager );
196+ 		List <CrashReportCategory > categoryList  = new  ArrayList <>();
197+ 		categoryList .add (category );
198+ 		categoryList .addAll (List .of (extraCategories ));
199+ 		LOGGER .error (crashReportToString (throwable , title , categoryList ));
187200	}
188201
189202	private  static  <T > void  setIngredientCategoryDetails (CrashReportCategory  category , IIngredientType <T > ingredientType , T  ingredient , IIngredientManager  ingredientManager ) {
@@ -203,7 +216,7 @@ private static <T> void setIngredientCategoryDetails(CrashReportCategory categor
203216		category .setDetail ("Error Info gathered from JEI" , () -> ingredientHelper .getErrorInfo (ingredient ));
204217	}
205218
206- 	private  static  String  crashReportToString (Throwable  t , String  title , CrashReportCategory ...  categories ) {
219+ 	public  static  String  crashReportToString (Throwable  t , String  title , Collection < CrashReportCategory >  categories ) {
207220		StringBuilder  sb  = new  StringBuilder ();
208221		sb .append (title );
209222		sb .append (":\n \n " );
0 commit comments