diff --git a/src/main/java/com/github/vfyjxf/nee/processor/ForestryRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/ForestryRecipeProcessor.java index f239439..7b78be7 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/ForestryRecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/ForestryRecipeProcessor.java @@ -2,15 +2,20 @@ package com.github.vfyjxf.nee.processor; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.IRecipeHandler; -import forestry.factory.recipes.nei.*; import javax.annotation.Nonnull; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.util.*; public class ForestryRecipeProcessor implements IRecipeProcessor { + @Nonnull + @Override + public Set getAllOverlayIdentifier() { + return new HashSet<>(Arrays.asList( + "forestry.bottler", "forestry.carpenter", "forestry.centrifuge", "forestry.fabricator", "forestry.fermenter", "forestry.moistener", "forestry.squeezer", "forestry.still" + )); + } + @Nonnull @Override public String getRecipeProcessorId() { @@ -20,94 +25,21 @@ public class ForestryRecipeProcessor implements IRecipeProcessor { @Nonnull @Override public List getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) { - if (recipe instanceof NEIHandlerBottler) { - - return bottlerHandler((NEIHandlerBottler) recipe, recipeIndex, true); - - } else if (recipe instanceof NEIHandlerCarpenter) { - - return carpenterHandler((NEIHandlerCarpenter) recipe, recipeIndex, true); - - } else if (recipe instanceof NEIHandlerCentrifuge) { - - return centrifugeHandler((NEIHandlerCentrifuge) recipe, recipeIndex, true); - - } else if (recipe instanceof NEIHandlerFabricator) { - - return fabricatorHandler((NEIHandlerFabricator) recipe, recipeIndex, true); - - } else if (recipe instanceof NEIHandlerMoistener) { - - return moistenerHandler((NEIHandlerMoistener) recipe, recipeIndex, true); - - } else if (recipe instanceof NEIHandlerSqueezer) { - - return squeezerHandler((NEIHandlerSqueezer) recipe, recipeIndex, true); - + List recipeInputs = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex)); } - return new ArrayList<>(); + return recipeInputs; } @Nonnull @Override public List getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { - if (recipe instanceof NEIHandlerBottler) { - - return bottlerHandler((NEIHandlerBottler) recipe, recipeIndex, false); - - } else if (recipe instanceof NEIHandlerCarpenter) { - - return carpenterHandler((NEIHandlerCarpenter) recipe, recipeIndex, false); - - } else if (recipe instanceof NEIHandlerCentrifuge) { - - return centrifugeHandler((NEIHandlerCentrifuge) recipe, recipeIndex, false); - - } else if (recipe instanceof NEIHandlerFabricator) { - - return fabricatorHandler((NEIHandlerFabricator) recipe, recipeIndex, false); - - } else if (recipe instanceof NEIHandlerMoistener) { - - return moistenerHandler((NEIHandlerMoistener) recipe, recipeIndex, false); - - } else if (recipe instanceof NEIHandlerSqueezer) { - - return squeezerHandler((NEIHandlerSqueezer) recipe, recipeIndex, false); - + List recipeOutput = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeOutput.add(recipe.getResultStack(recipeIndex)); } - return new ArrayList<>(); + return recipeOutput; } - private List bottlerHandler(NEIHandlerBottler base, int recipeIndex, boolean getInput) { - return getInput ? base.getIngredientStacks(recipeIndex) : Collections.singletonList(base.getResultStack(recipeIndex)); - } - - private List carpenterHandler(NEIHandlerCarpenter base, int recipeIndex, boolean getInput) { - return getInput ? base.getIngredientStacks(recipeIndex) : Collections.singletonList(base.getResultStack(recipeIndex)); - } - - private List centrifugeHandler(NEIHandlerCentrifuge base, int recipeIndex, boolean getInput) { - return getInput ? base.getIngredientStacks(recipeIndex) : base.getOtherStacks(recipeIndex); - } - - private List fabricatorHandler(NEIHandlerFabricator base, int recipeIndex, boolean getInput) { - List recipeInput = new ArrayList<>(base.getIngredientStacks(recipeIndex)); - recipeInput.addAll(base.getOtherStacks(recipeIndex)); - return getInput ? recipeInput : Collections.singletonList(base.getResultStack(recipeIndex)); - } - - //Fermenter doesn't support, because it doesn't have an item output - - private List moistenerHandler(NEIHandlerMoistener base, int recipeIndex, boolean getInput) { - List recipeInput = new ArrayList<>(base.getIngredientStacks(recipeIndex)); - recipeInput.addAll(base.getOtherStacks(recipeIndex)); - return getInput ? recipeInput : Collections.singletonList(base.getResultStack(recipeIndex)); - } - - private List squeezerHandler(NEIHandlerSqueezer base, int recipeIndex, boolean getInput) { - return getInput ? base.getIngredientStacks(recipeIndex) : Collections.singletonList(base.getResultStack(recipeIndex)); - } - //Still doesn't need support - }