Skip to content

Commit

Permalink
Add a singular "setInput" method to IIngredients
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Sep 27, 2016
1 parent 3d4b37e commit 469fd82
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/mezz/jei/api/ingredients/IIngredients.java
Expand Up @@ -18,6 +18,14 @@
* @since JEI 3.11.0
*/
public interface IIngredients {
/**
* Sets a single recipe input. For recipes with only one input slot.
*
* @param ingredientClass The class of ingredient: ItemStack.class, FluidStack.class, etc.
* @param input The list of ingredients representing each input slot.
*/
<T> void setInput(Class<T> ingredientClass, T input);

/**
* Sets the recipe's inputs. Each list element represents one slot.
*
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/mezz/jei/plugins/jei/debug/DebugRecipe.java
Expand Up @@ -15,6 +15,8 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
Expand Down Expand Up @@ -43,6 +45,8 @@ public void getIngredients(IIngredients ingredients) {

ingredients.setInputs(FluidStack.class, Arrays.asList(water, lava));

ingredients.setInput(ItemStack.class, new ItemStack(Items.STICK));

ingredients.setInputLists(DebugIngredient.class, Collections.singletonList(
Arrays.asList(new DebugIngredient(0), new DebugIngredient(1))
));
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/mezz/jei/util/Ingredients.java
Expand Up @@ -16,6 +16,11 @@ public class Ingredients implements IIngredients {
private final Map<Class, List> outputs = new HashMap<Class, List>();
private boolean used = false; // check that the addon used this at all. legacy addons will not

@Override
public <T> void setInput(Class<T> ingredientClass, T input) {
setInputs(ingredientClass, Collections.singletonList(input));
}

@Override
public <T> void setInputLists(Class<T> ingredientClass, List<List<T>> inputs) {
this.used = true;
Expand Down

0 comments on commit 469fd82

Please sign in to comment.