Skip to content

Commit

Permalink
[API] Add methods to create smelting and anvil recipes (#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohron authored and mezz committed Apr 19, 2017
1 parent 57261d0 commit acd6390
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -5,4 +5,4 @@ curse_project_id=238222

version_major=4
version_minor=3
version_patch=2
version_patch=3
28 changes: 27 additions & 1 deletion src/api/java/mezz/jei/api/IRecipeRegistry.java
Expand Up @@ -124,9 +124,35 @@ public interface IRecipeRegistry {
* By default, all smelting recipes from {@link FurnaceRecipes#smeltingList} are already added by JEI.
*
* @since JEI 4.2.7
* @deprecated since JEI 4.3.3. Use {@link #createSmeltingRecipe(List, ItemStack)}
*/
@Deprecated
void addSmeltingRecipe(List<ItemStack> inputs, ItemStack output);

/**
* Create a new smelting recipe.
* Use {@link #addRecipe(IRecipeWrapper, String)} to add the recipe while the game is running.
* By default, all smelting recipes from {@link FurnaceRecipes#smeltingList} are already added by JEI.
*
* @param inputs the list of possible inputs to rotate through
* @param output the output
* @since JEI 4.3.3
*/
IRecipeWrapper createSmeltingRecipe(List<ItemStack> inputs, ItemStack output);

/**
* Create a new anvil recipe.
* Use {@link #addRecipe(IRecipeWrapper, String)} to add the recipe while the game is running.
*
* @param leftInput the left input
* @param rightInputs the list of possible right inputs to rotate through
* @param outputs the list of possible outputs to rotate through
*
* @return the {@link IRecipeWrapper} for this recipe.
* @since JEI 4.3.3
*/
IRecipeWrapper createAnvilRecipe(ItemStack leftInput, List<ItemStack> rightInputs, List<ItemStack> outputs);

/**
* Remove a recipe while the game is running.
*
Expand Down Expand Up @@ -161,7 +187,7 @@ public interface IRecipeRegistry {
* Remove a recipe while the game is running.
*
* @since JEI 4.2.2
* @deprecated since JEI 4.3.0. Use {@link #removeRecipe(Object, String)}
* @deprecated since JEI 4.3.0. Use {@link #removeRecipe(IRecipeWrapper, String)}
*/
@Deprecated
void removeRecipe(Object recipe);
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/mezz/jei/recipes/RecipeRegistry.java
Expand Up @@ -35,6 +35,7 @@
import mezz.jei.gui.recipes.RecipeClickableArea;
import mezz.jei.gui.recipes.RecipeLayout;
import mezz.jei.ingredients.Ingredients;
import mezz.jei.plugins.vanilla.anvil.AnvilRecipeWrapper;
import mezz.jei.plugins.vanilla.furnace.SmeltingRecipe;
import mezz.jei.util.ErrorUtil;
import mezz.jei.util.Log;
Expand Down Expand Up @@ -376,6 +377,7 @@ private <T> void removeRecipeUnchecked(T recipe, IRecipeCategory recipeCategory)
}

@Override
@Deprecated
public void addSmeltingRecipe(List<ItemStack> inputs, ItemStack output) {
ErrorUtil.checkNotEmpty(inputs, "inputs");
Preconditions.checkNotNull(output, "null output");
Expand All @@ -384,6 +386,24 @@ public void addSmeltingRecipe(List<ItemStack> inputs, ItemStack output) {
addRecipe(smeltingRecipe);
}

@Override
public IRecipeWrapper createSmeltingRecipe(List<ItemStack> inputs, ItemStack output) {
ErrorUtil.checkNotEmpty(inputs, "inputs");
ErrorUtil.checkNotEmpty(output);

return new SmeltingRecipe(inputs, output);
}

@Override
public IRecipeWrapper createAnvilRecipe(ItemStack leftInput, List<ItemStack> rightInputs, List<ItemStack> outputs) {
ErrorUtil.checkNotEmpty(leftInput);
ErrorUtil.checkNotEmpty(rightInputs, "rightInputs");
ErrorUtil.checkNotEmpty(outputs, "outputs");
Preconditions.checkArgument(rightInputs.size() == outputs.size(), "Input and output sizes must match.");

return new AnvilRecipeWrapper(leftInput, rightInputs, outputs);
}

@Override
public List<IRecipeCategory> getRecipeCategories() {
for (IRecipeCategory recipeCategory : this.checkIfEmptyRecipeCategories) {
Expand Down

0 comments on commit acd6390

Please sign in to comment.