package mezz.jei.api.ingredients;

import javax.annotation.Nullable;
import java.util.Collection;
import java.util.List;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.util.ITooltipFlag;

/**
 * Renders a type of ingredient in JEI's item list and recipes.
 * <p>
 * If you have a new type of ingredient to add to JEI, you will have to implement this in order to use
 * {@link IModIngredientRegistration#register(Class, Collection, IIngredientHelper, IIngredientRenderer)}
 *
 * @since JEI 3.11.0
 */
public interface IIngredientRenderer<T> {
	/**
	 * Renders an ingredient at a specific location.
	 *
	 * @param minecraft  The minecraft instance.
	 * @param xPosition  The x position to render the ingredient.
	 * @param yPosition  The y position to render the ingredient.
	 * @param ingredient the ingredient to render. May be null, some renderers (like fluid tanks) will render a
	 *                   background even if there is no ingredient.
	 */
	void render(Minecraft minecraft, int xPosition, int yPosition, @Nullable T ingredient);

	/**
	 * Get the tooltip text for this ingredient. JEI renders the tooltip based on this.
	 *
	 * @param minecraft   The minecraft instance.
	 * @param ingredient  The ingredient to get the tooltip for.
	 * @param tooltipFlag Whether to show advanced information on item tooltips, toggled by F3+H
	 * @return The tooltip text for the ingredient.
	 *
	 * @since JEI 4.6.0
	 */
	default List<String> getTooltip(Minecraft minecraft, T ingredient, ITooltipFlag tooltipFlag) {
		// you should override this method. this default method is to keep old JEI plugins from crashing.
		return getTooltip(minecraft, ingredient, tooltipFlag == ITooltipFlag.TooltipFlags.ADVANCED);
	}

	/**
	 * Get the tooltip font renderer for this ingredient. JEI renders the tooltip based on this.
	 *
	 * @param minecraft  The minecraft instance.
	 * @param ingredient The ingredient to get the tooltip for.
	 * @return The font renderer for the ingredient.
	 */
	default FontRenderer getFontRenderer(Minecraft minecraft, T ingredient) {
		return minecraft.fontRenderer;
	}

	// DEPRECATED BELOW

	/**
	 * Get the tooltip text for this ingredient. JEI renders the tooltip based on this.
	 *
	 * @param minecraft  The minecraft instance.
	 * @param ingredient The ingredient to get the tooltip for.
	 * @return The tooltip text for the ingredient.
	 *
	 * @deprecated since JEI 4.3.6, use {@link #getTooltip(Minecraft, T, boolean)}
	 */
	@Deprecated
	default List<String> getTooltip(Minecraft minecraft, T ingredient) {
		throw new UnsupportedOperationException("Calling old getTooltip is not supported.");
	}

	/**
	 * Get the tooltip text for this ingredient. JEI renders the tooltip based on this.
	 *
	 * @param minecraft  The minecraft instance.
	 * @param ingredient The ingredient to get the tooltip for.
	 * @param advanced   Whether to show advanced information on item tooltips, toggled by F3+H
	 * @return The tooltip text for the ingredient.
	 *
	 * @since JEI 4.3.6
	 * @deprecated since JEI 4.6.0.
	 */
	@Deprecated
	default List<String> getTooltip(Minecraft minecraft, T ingredient, boolean advanced) {
		throw new UnsupportedOperationException("Calling old getTooltip is not supported.");
	}
}

@@ -2365,32 +2365,125 @@
 he tooltip for.%0A
+%09 * @param advanced   Whether to show advanced information on item tooltips, toggled by F3+H%0A
 %09 * @return The 
@@ -2520,35 +2520,24 @@
 t.%0A%09 *%0A%09 * @
-deprecated 
 since JEI 4.
@@ -2543,56 +2543,41 @@
 .3.6
-, use %7B@link #getTooltip(Minecraft, T, boolean)%7D
+%0A%09 * @deprecated since JEI 4.6.0.
 %0A%09 *
@@ -2661,96 +2661,71 @@
 ient
-) %7B%0A%09%09throw new UnsupportedOperationException(%22Calling old getTooltip is not supported.%22
+, boolean advanced) %7B%0A%09%09return getTooltip(minecraft, ingredient
 );%0A%09
@@ -2932,101 +2932,8 @@
 or.%0A
-%09 * @param advanced   Whether to show advanced information on item tooltips, toggled by F3+H%0A
 %09 * 
@@ -2978,32 +2978,43 @@
 dient.%0A%09 *%0A%09 * @
+deprecated 
 since JEI 4.3.6%0A
@@ -3016,41 +3016,61 @@
 .3.6
-%0A%09 * @deprecated since JEI 4.6.0.
+, use %7B@link #getTooltip(Minecraft, T, ITooltipFlag)%7D
 %0A%09 *
@@ -3150,34 +3150,16 @@
 gredient
-, boolean advanced
 ) %7B%0A%09%09th

Fix #1224 Add better support for old IIngredientRenderer tooltip implementations