Skip to content

Commit

Permalink
Use IIngredientType instead of raw ingredient Classes
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Aug 13, 2018
1 parent e57a772 commit 3330e87
Show file tree
Hide file tree
Showing 59 changed files with 856 additions and 356 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Expand Up @@ -4,5 +4,5 @@ mcp_mappings=snapshot_20180812
curse_project_id=238222

version_major=4
version_minor=11
version_patch=1
version_minor=12
version_patch=0
3 changes: 2 additions & 1 deletion src/api/java/mezz/jei/api/IIngredientFilter.java
Expand Up @@ -2,6 +2,7 @@

import com.google.common.collect.ImmutableList;
import mezz.jei.api.ingredients.IIngredientRegistry;
import mezz.jei.api.recipe.IIngredientType;

/**
* The IIngredientFilter is JEI's filter that can be set by players or controlled by mods.
Expand All @@ -23,7 +24,7 @@ public interface IIngredientFilter {

/**
* @return a list containing all ingredients that match the current filter.
* To get all the ingredients known to JEI, see {@link IIngredientRegistry#getAllIngredients(Class)}.
* To get all the ingredients known to JEI, see {@link IIngredientRegistry#getAllIngredients(IIngredientType)}.
*/
ImmutableList<Object> getFilteredIngredients();
}
3 changes: 2 additions & 1 deletion src/api/java/mezz/jei/api/IItemListOverlay.java
Expand Up @@ -2,6 +2,7 @@

import com.google.common.collect.ImmutableList;
import mezz.jei.api.ingredients.IIngredientRegistry;
import mezz.jei.api.recipe.IIngredientType;
import net.minecraft.item.ItemStack;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -49,7 +50,7 @@ public interface IItemListOverlay {

/**
* @return a list containing all stacks that match the current filter.
* To get all the ItemStacks known to JEI, see {@link IIngredientRegistry#getAllIngredients(Class)}.
* To get all the ItemStacks known to JEI, see {@link IIngredientRegistry#getAllIngredients(IIngredientType)}.
* @deprecated since JEI 4.5.0, use {@link IIngredientFilter#getFilteredIngredients()}
*/
@Deprecated
Expand Down
49 changes: 41 additions & 8 deletions src/api/java/mezz/jei/api/IModRegistry.java
Expand Up @@ -4,6 +4,7 @@
import mezz.jei.api.gui.IGhostIngredientHandler;
import mezz.jei.api.gui.IGuiScreenHandler;
import mezz.jei.api.ingredients.IIngredientRegistry;
import mezz.jei.api.recipe.IIngredientType;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import mezz.jei.api.recipe.IRecipeHandler;
Expand Down Expand Up @@ -108,28 +109,28 @@ public interface IModRegistry {
* Description pages show in the recipes for an ingredient and tell the player a little bit about it.
*
* @param ingredient the ingredient to describe
* @param ingredientClass the class of the ingredient
* @param ingredientType the type of the ingredient
* @param descriptionKeys Localization keys for info text.
* New lines can be added with "\n" or by giving multiple descriptionKeys.
* Long lines are wrapped automatically.
* Very long entries will span multiple pages automatically.
* @since JEI 4.5.0
* @since JEI 4.12.0
*/
<T> void addIngredientInfo(T ingredient, Class<? extends T> ingredientClass, String... descriptionKeys);
<T> void addIngredientInfo(T ingredient, IIngredientType<T> ingredientType, String... descriptionKeys);

/**
* Add an info page for multiple ingredients together.
* Description pages show in the recipes for an ingredient and tell the player a little bit about it.
*
* @param ingredients the ingredients to describe
* @param ingredientClass the class of the ingredients
* @param ingredientType the type of the ingredients
* @param descriptionKeys Localization keys for info text.
* New lines can be added with "\n" or by giving multiple descriptionKeys.
* Long lines are wrapped automatically.
* Very long entries will span multiple pages automatically.
* @since JEI 4.5.0
* @since JEI 4.12.0
*/
<T> void addIngredientInfo(List<T> ingredients, Class<? extends T> ingredientClass, String... descriptionKeys);
<T> void addIngredientInfo(List<T> ingredients, IIngredientType<T> ingredientType, String... descriptionKeys);

/**
* Get the registry for setting up recipe transfer.
Expand All @@ -146,6 +147,38 @@ public interface IModRegistry {

// DEPRECATED BELOW

/**
* Add an info page for multiple ingredients together.
* Description pages show in the recipes for an ingredient and tell the player a little bit about it.
*
* @param ingredients the ingredients to describe
* @param ingredientClass the class of the ingredients
* @param descriptionKeys Localization keys for info text.
* New lines can be added with "\n" or by giving multiple descriptionKeys.
* Long lines are wrapped automatically.
* Very long entries will span multiple pages automatically.
* @since JEI 4.5.0
* @deprecated since JEI 4.12.0. Use {@link #addIngredientInfo(List, IIngredientType, String...)}
*/
@Deprecated
<T> void addIngredientInfo(List<T> ingredients, Class<? extends T> ingredientClass, String... descriptionKeys);

/**
* Add an info page for an ingredient.
* Description pages show in the recipes for an ingredient and tell the player a little bit about it.
*
* @param ingredient the ingredient to describe
* @param ingredientClass the class of the ingredient
* @param descriptionKeys Localization keys for info text.
* New lines can be added with "\n" or by giving multiple descriptionKeys.
* Long lines are wrapped automatically.
* Very long entries will span multiple pages automatically.
* @since JEI 4.5.0
* @deprecated since JEI 4.12.0. Use {@link #addIngredientInfo(Object, IIngredientType, String...)}
*/
@Deprecated
<T> void addIngredientInfo(T ingredient, Class<? extends T> ingredientClass, String... descriptionKeys);

/**
* Add the recipe categories provided by this plugin.
*
Expand Down Expand Up @@ -193,13 +226,13 @@ public interface IModRegistry {
* New lines can be added with "\n" or by giving multiple descriptionKeys.
* Long lines are wrapped automatically.
* Very long entries will span multiple pages automatically.
* @deprecated since JEI 4.5.0. Use {@link #addIngredientInfo(Object, Class, String...)}
* @deprecated since JEI 4.5.0. Use {@link #addIngredientInfo(Object, IIngredientType, String...)}
*/
@Deprecated
void addDescription(ItemStack itemStack, String... descriptionKeys);

/**
* @deprecated since JEI 4.5.0. Use {@link #addIngredientInfo(List, Class, String...)}
* @deprecated since JEI 4.5.0. Use {@link #addIngredientInfo(List, IIngredientType, String...)}
*/
@Deprecated
void addDescription(List<ItemStack> itemStacks, String... descriptionKeys);
Expand Down
3 changes: 2 additions & 1 deletion src/api/java/mezz/jei/api/gui/IGuiIngredientGroup.java
Expand Up @@ -10,6 +10,7 @@
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.IModIngredientRegistration;
import mezz.jei.api.recipe.IFocus;
import mezz.jei.api.recipe.IIngredientType;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;

Expand Down Expand Up @@ -68,7 +69,7 @@ public interface IGuiIngredientGroup<T> {
* Initialize a guiIngredient for the given slot.
* This can handle mod ingredients registered with {@link IModIngredientRegistration}.
* <p>
* Uses the default {@link IIngredientRenderer} registered for the ingredient list in {@link IModIngredientRegistration#register(Class, Collection, IIngredientHelper, IIngredientRenderer)}
* Uses the default {@link IIngredientRenderer} registered for the ingredient list in {@link IModIngredientRegistration#register(IIngredientType, Collection, IIngredientHelper, IIngredientRenderer)}
* Uses the same 16x16 size as the ingredient list.
* <p>
* For more advanced control over rendering, use {@link #init(int, boolean, IIngredientRenderer, int, int, int, int, int, int)}
Expand Down
19 changes: 17 additions & 2 deletions src/api/java/mezz/jei/api/gui/IRecipeLayout.java
Expand Up @@ -5,6 +5,7 @@
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.IModIngredientRegistration;
import mezz.jei.api.recipe.IFocus;
import mezz.jei.api.recipe.IIngredientType;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;

Expand All @@ -29,15 +30,16 @@ public interface IRecipeLayout {
IGuiFluidStackGroup getFluidStacks();

/**
* Get all the ingredients of one class that are displayed on this recipe layout.
* Get all the ingredients of one type that are displayed on this recipe layout.
* Init and set them in your recipe category.
* <p>
* This method is for handling custom item types, registered with {@link IModIngredientRegistration}.
*
* @see #getItemStacks()
* @see #getFluidStacks()
* @since JEI 4.12.0
*/
<T> IGuiIngredientGroup<T> getIngredientsGroup(Class<T> ingredientClass);
<T> IGuiIngredientGroup<T> getIngredientsGroup(IIngredientType<T> ingredientType);

/**
* The current search focus. Set by the player when they look up the recipe. The object being looked up is the focus.
Expand Down Expand Up @@ -66,4 +68,17 @@ public interface IRecipeLayout {
* @since JEI 4.0.2
*/
void setShapeless();

/**
* Get all the ingredients of one class that are displayed on this recipe layout.
* Init and set them in your recipe category.
* <p>
* This method is for handling custom item types, registered with {@link IModIngredientRegistration}.
*
* @see #getItemStacks()
* @see #getFluidStacks()
* @deprecated since JEI 4.12.0. Use {@link #getIngredientsGroup(IIngredientType)}
*/
@Deprecated
<T> IGuiIngredientGroup<T> getIngredientsGroup(Class<T> ingredientClass);
}
5 changes: 3 additions & 2 deletions src/api/java/mezz/jei/api/ingredients/IIngredientHelper.java
Expand Up @@ -5,14 +5,15 @@
import java.util.Collection;
import java.util.List;

import mezz.jei.api.recipe.IIngredientType;
import net.minecraft.item.ItemStack;

/**
* An ingredient helper allows JEI to get information about ingredients for searching and other purposes.
* An ingredient is anything used in a recipe, like ItemStacks and FluidStacks.
* <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)}
* {@link IModIngredientRegistration#register(IIngredientType, Collection, IIngredientHelper, IIngredientRenderer)}
*
* @since JEI 3.11.0
*/
Expand Down Expand Up @@ -82,7 +83,7 @@ default String getDisplayModId(V ingredient) {
* @since JEI 4.8.3
*/
default ItemStack getCheatItemStack(V ingredient) {
return cheatIngredient(ingredient, false);
return ItemStack.EMPTY;
}

/**
Expand Down
95 changes: 83 additions & 12 deletions src/api/java/mezz/jei/api/ingredients/IIngredientRegistry.java
@@ -1,6 +1,7 @@
package mezz.jei.api.ingredients;

import mezz.jei.api.IModRegistry;
import mezz.jei.api.recipe.IIngredientType;
import net.minecraft.item.ItemStack;

import java.util.Collection;
Expand All @@ -14,20 +15,22 @@
*/
public interface IIngredientRegistry {
/**
* Returns an unmodifiable collection of all the ingredients known to JEI, of the specified class.
* @since JEI 4.7.3
* Returns an unmodifiable collection of all the ingredients known to JEI, of the specified type.
* @since JEI 4.12.0
*/
<V> Collection<V> getAllIngredients(Class<V> ingredientClass);
<V> Collection<V> getAllIngredients(IIngredientType<V> ingredientType);

/**
* Returns the appropriate ingredient helper for this ingredient.
*/
<V> IIngredientHelper<V> getIngredientHelper(V ingredient);

/**
* Returns the appropriate ingredient helper for this ingredient class
* Returns the appropriate ingredient helper for this ingredient type.
*
* @since JEI 4.12.0
*/
<V> IIngredientHelper<V> getIngredientHelper(Class<? extends V> ingredientClass);
<V> IIngredientHelper<V> getIngredientHelper(IIngredientType<V> ingredientType);

/**
* Returns the ingredient renderer for this ingredient.
Expand All @@ -36,14 +39,17 @@ public interface IIngredientRegistry {

/**
* Returns the ingredient renderer for this ingredient class.
* @since JEI 4.12.0
*/
<V> IIngredientRenderer<V> getIngredientRenderer(Class<? extends V> ingredientClass);
<V> IIngredientRenderer<V> getIngredientRenderer(IIngredientType<V> ingredientType);

/**
* Returns an unmodifiable collection of all registered ingredient classes.
* Without addons, there is ItemStack.class and FluidStack.class.
* Returns an unmodifiable collection of all registered ingredient types.
* Without addons, there are {@link VanillaTypes#ITEM} and {@link VanillaTypes#FLUID}.
*
* @since JEI 4.12.0
*/
Collection<Class> getRegisteredIngredientClasses();
Collection<IIngredientType> getRegisteredIngredientTypes();

/**
* Returns an unmodifiable list of all the ItemStacks that can be used as fuel in a vanilla furnace.
Expand All @@ -55,28 +61,93 @@ public interface IIngredientRegistry {
*/
List<ItemStack> getPotionIngredients();

/**
* Add new ingredients to JEI at runtime.
* Used by mods that have items created while the game is running, or use the server to define items.
*
* @since JEI 4.12.0
*/
<V> void addIngredientsAtRuntime(IIngredientType<V> ingredientType, Collection<V> ingredients);

/**
* Remove ingredients from JEI at runtime.
* Used by mods that have items created while the game is running, or use the server to define items.
*
* @since JEI 4.12.0
*/
<V> void removeIngredientsAtRuntime(IIngredientType<V> ingredientType, Collection<V> ingredients);

/**
* Helper method to get ingredient type for an ingredient.
*
* @since JEI 4.12.0
*/
<V> IIngredientType<V> getIngredientType(V ingredient);

/**
* Helper method to get ingredient type from a legacy ingredient class.
*
* @since JEI 4.12.0
*/
<V> IIngredientType<V> getIngredientType(Class<? extends V> ingredientClass);

/**
* Returns an unmodifiable collection of all the ingredients known to JEI, of the specified class.
* @since JEI 4.7.3
* @deprecated since JEI 4.12.0. Use {@link #getAllIngredients(IIngredientType)}
*/
@Deprecated
<V> Collection<V> getAllIngredients(Class<V> ingredientClass);

/**
* Returns the appropriate ingredient helper for this ingredient class.
* @deprecated since JEI 4.12.0. Use {@link #getIngredientHelper(IIngredientType)}
*/
@Deprecated
<V> IIngredientHelper<V> getIngredientHelper(Class<? extends V> ingredientClass);

/**
* Returns the ingredient renderer for this ingredient class.
* @deprecated since JEI 4.12.0. Use {@link #getIngredientRenderer(IIngredientType)}
*/
@Deprecated
<V> IIngredientRenderer<V> getIngredientRenderer(Class<? extends V> ingredientClass);

/**
* Returns an unmodifiable collection of all registered ingredient classes.
* Without addons, there is ItemStack.class and FluidStack.class.
*
* @deprecated since JEI 4.12.0. Use {@link #getRegisteredIngredientTypes()}
*/
@Deprecated
Collection<Class> getRegisteredIngredientClasses();

/**
* Add new ingredients to JEI at runtime.
* Used by mods that have items created while the game is running, or use the server to define items.
*
* @since JEI 4.8.2
* @deprecated since JEi 4.12.0. Use {@link #addIngredientsAtRuntime(IIngredientType, Collection)}
*/
@Deprecated
<V> void addIngredientsAtRuntime(Class<V> ingredientClass, Collection<V> ingredients);

/**
* Remove ingredients from JEI at runtime.
* Used by mods that have items created while the game is running, or use the server to define items.
*
* @since JEI 4.8.2
* @deprecated since JEI 4.12.0. Use {@link #removeIngredientsAtRuntime(IIngredientType, Collection)}
*/
@Deprecated
<V> void removeIngredientsAtRuntime(Class<V> ingredientClass, Collection<V> ingredients);

/**
* Add new ingredients to JEI at runtime.
* Used by mods that have items created while the game is running, or use the server to define items.
*
* @since JEI 4.0.2
* @deprecated since JEI 4.7.3. Use {@link #addIngredientsAtRuntime(Class, Collection)}
* @deprecated since JEI 4.7.3. Use {@link #addIngredientsAtRuntime(IIngredientType, Collection)}
*/
@Deprecated
<V> void addIngredientsAtRuntime(Class<V> ingredientClass, List<V> ingredients);
Expand All @@ -86,15 +157,15 @@ public interface IIngredientRegistry {
* Used by mods that have items created while the game is running, or use the server to define items.
*
* @since JEI 4.3.5
* @deprecated since JEI 4.7.3. Use {@link #removeIngredientsAtRuntime(Class, Collection)}
* @deprecated since JEI 4.7.3. Use {@link #removeIngredientsAtRuntime(IIngredientType, Collection)}
*/
@Deprecated
<V> void removeIngredientsAtRuntime(Class<V> ingredientClass, List<V> ingredients);

/**
* Returns an unmodifiable list of all the ingredients known to JEI, of the specified class.
*
* @deprecated since JEI 4.7.3. Use {@link #getAllIngredients(Class)}
* @deprecated since JEI 4.7.3. Use {@link #getAllIngredients(IIngredientType)}
*/
@Deprecated
<V> List<V> getIngredients(Class<V> ingredientClass);
Expand Down

0 comments on commit 3330e87

Please sign in to comment.