Skip to content

Commit

Permalink
Add support for anvil recipe left side being a list (mezz#1419)
Browse files Browse the repository at this point in the history
  • Loading branch information
tterrag1098 authored and mezz committed Dec 9, 2018
1 parent 7aa957d commit 7fb2b05
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ curse_project_id=238222

version_major=4
version_minor=14
version_patch=0
version_patch=1
12 changes: 12 additions & 0 deletions src/api/java/mezz/jei/api/recipe/IVanillaRecipeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ public interface IVanillaRecipeFactory {
*/
IRecipeWrapper createAnvilRecipe(ItemStack leftInput, List<ItemStack> rightInputs, List<ItemStack> outputs);

/**
* Adds an anvil recipe for the given inputs and output.
* The number of inputs in the left and right side must match.
*
* @param leftInputs The itemStack(s) placed on the left slot.
* @param rightInputs The itemStack(s) placed on the right slot.
* @param outputs The resulting itemStack(s).
* @return the {@link IRecipeWrapper} for this recipe.
* @since JEI 4.14.1
*/
IRecipeWrapper createAnvilRecipe(List<ItemStack> leftInputs, List<ItemStack> rightInputs, List<ItemStack> outputs);

/**
* Create a new smelting recipe.
* By default, all smelting recipes from {@link FurnaceRecipes#smeltingList} are already added by JEI.
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/mezz/jei/plugins/vanilla/VanillaRecipeFactory.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mezz.jei.plugins.vanilla;

import java.util.Collections;
import java.util.List;

import com.google.common.base.Preconditions;
Expand All @@ -19,7 +20,18 @@ public IRecipeWrapper createAnvilRecipe(ItemStack leftInput, List<ItemStack> rig
ErrorUtil.checkNotEmpty(outputs, "outputs");
Preconditions.checkArgument(rightInputs.size() == outputs.size(), "Input and output sizes must match.");

return new AnvilRecipeWrapper(leftInput, rightInputs, outputs);
return new AnvilRecipeWrapper(Collections.singletonList(leftInput), rightInputs, outputs);
}

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

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public class AnvilRecipeWrapper implements IRecipeWrapper {
private ItemStack lastRightStack;
private int lastCost;

public AnvilRecipeWrapper(ItemStack leftInput, List<ItemStack> rightInputs, List<ItemStack> outputs) {
public AnvilRecipeWrapper(List<ItemStack> leftInput, List<ItemStack> rightInputs, List<ItemStack> outputs) {
this.inputs = Lists.newArrayList();
this.inputs.add(Collections.singletonList(leftInput));
this.inputs.add(leftInput);
this.inputs.add(rightInputs);

this.output = Collections.singletonList(outputs);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mezz/jei/startup/ModRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public void addAnvilRecipe(ItemStack leftInput, List<ItemStack> rightInputs, Lis
ErrorUtil.checkNotEmpty(outputs, "outputs");
Preconditions.checkArgument(rightInputs.size() == outputs.size(), "Input and output sizes must match.");

AnvilRecipeWrapper anvilRecipeWrapper = new AnvilRecipeWrapper(leftInput, rightInputs, outputs);
AnvilRecipeWrapper anvilRecipeWrapper = new AnvilRecipeWrapper(Collections.singletonList(leftInput), rightInputs, outputs);
addRecipes(Collections.singletonList(anvilRecipeWrapper), VanillaRecipeCategoryUid.ANVIL);
}

Expand Down

0 comments on commit 7fb2b05

Please sign in to comment.