88import  mezz .jei .api .ingredients .IIngredientType ;
99import  mezz .jei .api .ingredients .ITypedIngredient ;
1010import  mezz .jei .api .recipe .RecipeIngredientRole ;
11+ import  mezz .jei .api .recipe .RecipeType ;
1112import  mezz .jei .api .runtime .IIngredientManager ;
1213import  mezz .jei .common .Internal ;
1314import  mezz .jei .common .util .ErrorUtil ;
@@ -27,9 +28,11 @@ public class OutputSlotTooltipCallback implements IRecipeSlotRichTooltipCallback
2728	private  static  final  Logger  LOGGER  = LogManager .getLogger ();
2829
2930	private  final  ResourceLocation  recipeName ;
31+ 	private  final  boolean  recipeFromSameModAsCategory ;
3032
31- 	public  OutputSlotTooltipCallback (ResourceLocation  recipeName ) {
33+ 	public  OutputSlotTooltipCallback (ResourceLocation  recipeName ,  RecipeType <?>  recipeType ) {
3234		this .recipeName  = recipeName ;
35+ 		this .recipeFromSameModAsCategory  = recipeName .getNamespace ().equals (recipeType .getUid ().getNamespace ());
3336	}
3437
3538	@ Override 
@@ -42,18 +45,7 @@ public void onRichTooltip(IRecipeSlotView recipeSlotView, ITooltipBuilder toolti
4245			return ;
4346		}
4447
45- 		IModIdHelper  modIdHelper  = Internal .getJeiRuntime ().getJeiHelpers ().getModIdHelper ();
46- 		if  (modIdHelper .isDisplayingModNameEnabled ()) {
47- 			String  ingredientModId  = getDisplayModId (displayedIngredient .get ());
48- 			if  (ingredientModId  != null ) {
49- 				String  recipeModId  = recipeName .getNamespace ();
50- 				if  (!recipeModId .equals (ingredientModId )) {
51- 					String  modName  = modIdHelper .getFormattedModNameForModId (recipeModId );
52- 					MutableComponent  recipeBy  = Component .translatable ("jei.tooltip.recipe.by" , modName );
53- 					tooltip .add (recipeBy .withStyle (ChatFormatting .GRAY ));
54- 				}
55- 			}
56- 		}
48+ 		addRecipeBy (tooltip , displayedIngredient .get ());
5749
5850		Minecraft  minecraft  = Minecraft .getInstance ();
5951		boolean  showAdvanced  = minecraft .options .advancedItemTooltips  || Screen .hasShiftDown ();
@@ -63,6 +55,27 @@ public void onRichTooltip(IRecipeSlotView recipeSlotView, ITooltipBuilder toolti
6355		}
6456	}
6557
58+ 	private  void  addRecipeBy (ITooltipBuilder  tooltip , ITypedIngredient <?> displayedIngredient ) {
59+ 		if  (recipeFromSameModAsCategory ) {
60+ 			return ;
61+ 		}
62+ 		IModIdHelper  modIdHelper  = Internal .getJeiRuntime ().getJeiHelpers ().getModIdHelper ();
63+ 		if  (!modIdHelper .isDisplayingModNameEnabled ()) {
64+ 			return ;
65+ 		}
66+ 		String  ingredientModId  = getDisplayModId (displayedIngredient );
67+ 		if  (ingredientModId  == null ) {
68+ 			return ;
69+ 		}
70+ 		String  recipeModId  = recipeName .getNamespace ();
71+ 		if  (recipeModId .equals (ingredientModId )) {
72+ 			return ;
73+ 		}
74+ 		String  modName  = modIdHelper .getFormattedModNameForModId (recipeModId );
75+ 		MutableComponent  recipeBy  = Component .translatable ("jei.tooltip.recipe.by" , modName );
76+ 		tooltip .add (recipeBy .withStyle (ChatFormatting .GRAY ));
77+ 	}
78+ 
6679	private  <T > @ Nullable  String  getDisplayModId (ITypedIngredient <T > typedIngredient ) {
6780		IIngredientManager  ingredientManager  = Internal .getJeiRuntime ().getIngredientManager ();
6881
0 commit comments