@@ -82,6 +82,7 @@ public class RecipeLayout<R> implements IRecipeLayoutDrawable<R>, IRecipeExtrasB
8282	private  final  ImmutableRect2i  recipeTransferButtonArea ;
8383	private  final  @ Nullable  ShapelessIcon  shapelessIcon ;
8484	private  final  RecipeLayoutInputHandler <R > inputHandler ;
85+ 	private  boolean  extrasCreated  = false ;
8586
8687	private  ImmutableRect2i  area ;
8788
@@ -122,7 +123,6 @@ public static <T> Optional<IRecipeLayoutDrawable<T>> create(
122123				recipeBackground ,
123124				recipeBorderPadding 
124125			);
125- 			recipeCategory .createRecipeExtras (recipeLayout , recipe , focuses );
126126			return  Optional .of (recipeLayout );
127127		} catch  (RuntimeException  | LinkageError  e ) {
128128			LOGGER .error ("Error caught from Recipe Category: {}" , recipeCategory .getRecipeType (), e );
@@ -176,13 +176,21 @@ public RecipeLayout(
176176		recipeCategory .onDisplayedIngredientsUpdate (recipe , Collections .unmodifiableList (recipeCategorySlots ), focuses );
177177	}
178178
179+ 	public  void  ensureRecipeExtrasAreCreated () {
180+ 		if  (!extrasCreated ) {
181+ 			extrasCreated  = true ;
182+ 			recipeCategory .createRecipeExtras (this , recipe , focuses );
183+ 		}
184+ 	}
185+ 
179186	@ Override 
180187	public  void  setPosition (int  posX , int  posY ) {
181188		area  = area .setPosition (posX , posY );
182189	}
183190
184191	@ Override 
185192	public  void  drawRecipe (GuiGraphics  guiGraphics , int  mouseX , int  mouseY ) {
193+ 		ensureRecipeExtrasAreCreated ();
186194		@ SuppressWarnings ("removal" )
187195		IDrawable  background  = recipeCategory .getBackground ();
188196
@@ -259,6 +267,7 @@ public void drawRecipe(GuiGraphics guiGraphics, int mouseX, int mouseY) {
259267
260268	@ Override 
261269	public  void  drawOverlays (GuiGraphics  guiGraphics , int  mouseX , int  mouseY ) {
270+ 		ensureRecipeExtrasAreCreated ();
262271		RenderSystem .setShaderColor (1.0F , 1.0F , 1.0F , 1.0F );
263272
264273		final  int  recipeMouseX  = mouseX  - area .getX ();
@@ -335,6 +344,7 @@ public Optional<IRecipeSlotDrawable> getRecipeSlotUnderMouse(double mouseX, doub
335344
336345	@ Override 
337346	public  Optional <RecipeSlotUnderMouse > getSlotUnderMouse (double  mouseX , double  mouseY ) {
347+ 		ensureRecipeExtrasAreCreated ();
338348		final  double  recipeMouseX  = mouseX  - area .getX ();
339349		final  double  recipeMouseY  = mouseY  - area .getY ();
340350
@@ -381,6 +391,7 @@ public IRecipeSlotsView getRecipeSlotsView() {
381391
382392	@ Override 
383393	public  IRecipeSlotDrawablesView  getRecipeSlots () {
394+ 		ensureRecipeExtrasAreCreated ();
384395		return  () -> Collections .unmodifiableList (recipeCategorySlots );
385396	}
386397
@@ -396,6 +407,7 @@ public IJeiInputHandler getInputHandler() {
396407
397408	@ Override 
398409	public  void  tick () {
410+ 		ensureRecipeExtrasAreCreated ();
399411		for  (IRecipeWidget  widget  : allWidgets ) {
400412			widget .tick ();
401413		}
0 commit comments