Simplify some code

This commit is contained in:
vfyjxf committed 2021-12-19 01:20:51 +08:00
1 parent 9963789272
commit 7ccf1b0767
28 files changed
+395 -326

No files matched your search

@@ -3,9 +3,11 @@ package com.github.vfyjxf.nee.processor;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import javax.annotation.Nonnull;
import java.util.*;
public class AvaritiaRecipeProcessor implements IRecipeProcessor {
@Nonnull
@Override
public Set<String> getAllOverlayIdentifier() {
return new HashSet<>(Arrays.asList(
@@ -13,30 +15,31 @@ public class AvaritiaRecipeProcessor implements IRecipeProcessor {
));
}
@Nonnull
@Override
public String getRecipeProcessorId() {
return "Avaritia";
}
@Nonnull
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
return new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
}
List<PositionedStack> recipeInputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex));
return recipeInputs;
}
return null;
return recipeInputs;
}
@Nonnull
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
List<PositionedStack> recipeOutput = new ArrayList<>();
recipeOutput.add(recipe.getResultStack(recipeIndex));
return recipeOutput;
}
List<PositionedStack> recipeOutput = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeOutput.add(recipe.getResultStack(recipeIndex));
return recipeOutput;
}
return null;
return recipeOutput;
}
}
@@ -3,12 +3,14 @@ package com.github.vfyjxf.nee.processor;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import javax.annotation.Nonnull;
import java.util.*;
/**
* @author vfyjxf
*/
public class BloodMagicRecipeProcessor implements IRecipeProcessor {
@Nonnull
@Override
public Set<String> getAllOverlayIdentifier() {
return new HashSet<>(Arrays.asList(
@@ -19,30 +21,31 @@ public class BloodMagicRecipeProcessor implements IRecipeProcessor {
));
}
@Nonnull
@Override
public String getRecipeProcessorId() {
return "BloodMagic";
}
@Nonnull
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
return new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
}
List<PositionedStack> recipeInputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex));
return recipeInputs;
}
return null;
return recipeInputs;
}
@Nonnull
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
List<PositionedStack> recipeOutputs = new ArrayList<>();
recipeOutputs.add(recipe.getResultStack(recipeIndex));
return recipeOutputs;
}
List<PositionedStack> recipeOutputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeOutputs.add(recipe.getResultStack(recipeIndex));
return recipeOutputs;
}
return null;
return recipeOutputs;
}
}
@@ -5,6 +5,8 @@ import buildcraft.compat.nei.RecipeHandlerIntegrationTable;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -13,11 +15,13 @@ import java.util.List;
*/
public class BuildCraftRecipeProcessor implements IRecipeProcessor {
@Nonnull
@Override
public String getRecipeProcessorId() {
return "BuildCraft";
}
@Nonnull
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
if (recipe instanceof RecipeHandlerAssemblyTable) {
@@ -25,9 +29,10 @@ public class BuildCraftRecipeProcessor implements IRecipeProcessor {
} else if (recipe instanceof RecipeHandlerIntegrationTable) {
return handlerIntegrationTableRecipe((RecipeHandlerIntegrationTable) recipe, recipeIndex, true);
}
return null;
return new ArrayList<>();
}
@Nonnull
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
if (recipe instanceof RecipeHandlerAssemblyTable) {
@@ -35,7 +40,7 @@ public class BuildCraftRecipeProcessor implements IRecipeProcessor {
} else if (recipe instanceof RecipeHandlerIntegrationTable) {
return handlerIntegrationTableRecipe((RecipeHandlerIntegrationTable) recipe, recipeIndex, false);
}
return null;
return new ArrayList<>();
}
private List<PositionedStack> handlerAssemblyTableRecipe(RecipeHandlerAssemblyTable recipe, int recipeIndex, boolean getInput) {
@@ -4,9 +4,11 @@ import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import crazypants.enderio.nei.SagMillRecipeHandler;
import javax.annotation.Nonnull;
import java.util.*;
public class EnderIORecipeProcessor implements IRecipeProcessor {
@Nonnull
@Override
public Set<String> getAllOverlayIdentifier() {
return new HashSet<>(Arrays.asList(
@@ -15,38 +17,40 @@ public class EnderIORecipeProcessor implements IRecipeProcessor {
));
}
@Nonnull
@Override
public String getRecipeProcessorId() {
return "EnderIO";
}
@Nonnull
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
return new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
}
}
return null;
List<PositionedStack> recipeInputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex));
return recipeInputs;
}
return recipeInputs;
}
@Nonnull
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
if(identifier!=null) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
List<PositionedStack> recipeOutputs = new ArrayList<>();
recipeOutputs.add(recipe.getResultStack(recipeIndex));
recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex));
//remove output if it's chance != 1
if(recipe instanceof SagMillRecipeHandler){
SagMillRecipeHandler.MillRecipe millRecipe = (SagMillRecipeHandler.MillRecipe) ((SagMillRecipeHandler) recipe).arecipes.get(recipeIndex);
recipeOutputs.removeIf(positionedStack -> millRecipe.getChanceForOutput(positionedStack.item) != 1.0F);
}
return recipeOutputs;
List<PositionedStack> recipeOutputs = new ArrayList<>();
if (identifier != null) {
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeOutputs.add(recipe.getResultStack(recipeIndex));
recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex));
//remove output if it's chance != 1
if (recipe instanceof SagMillRecipeHandler) {
SagMillRecipeHandler.MillRecipe millRecipe = (SagMillRecipeHandler.MillRecipe) ((SagMillRecipeHandler) recipe).arecipes.get(recipeIndex);
recipeOutputs.removeIf(positionedStack -> millRecipe.getChanceForOutput(positionedStack.item) != 1.0F);
}
return recipeOutputs;
}
}
return null;
return recipeOutputs;
}
}
@@ -4,17 +4,20 @@ 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;
public class ForestryRecipeProcessor implements IRecipeProcessor {
@Nonnull
@Override
public String getRecipeProcessorId() {
return "Forestry";
}
@Nonnull
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
if (recipe instanceof NEIHandlerBottler) {
@@ -42,9 +45,10 @@ public class ForestryRecipeProcessor implements IRecipeProcessor {
return squeezerHandler((NEIHandlerSqueezer) recipe, recipeIndex, true);
}
return null;
return new ArrayList<>();
}
@Nonnull
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
if (recipe instanceof NEIHandlerBottler) {
@@ -72,7 +76,7 @@ public class ForestryRecipeProcessor implements IRecipeProcessor {
return squeezerHandler((NEIHandlerSqueezer) recipe, recipeIndex, false);
}
return null;
return new ArrayList<>();
}
private List<PositionedStack> bottlerHandler(NEIHandlerBottler base, int recipeIndex, boolean getInput) {
@@ -93,7 +97,7 @@ public class ForestryRecipeProcessor implements IRecipeProcessor {
return getInput ? recipeInput : Collections.singletonList(base.getResultStack(recipeIndex));
}
//Fermenter doesn't support, because it doesn't has a item output
//Fermenter doesn't support, because it doesn't have an item output
private List<PositionedStack> moistenerHandler(NEIHandlerMoistener base, int recipeIndex, boolean getInput) {
List<PositionedStack> recipeInput = new ArrayList<>(base.getIngredientStacks(recipeIndex));
@@ -4,12 +4,14 @@ import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import gregtech.api.util.GTPP_Recipe;
import javax.annotation.Nonnull;
import java.util.*;
/**
* @author vfyjxf
*/
public class GTPPRecipeProcessor implements IRecipeProcessor {
@Nonnull
@Override
public Set<String> getAllOverlayIdentifier() {
HashSet<String> identifiers = new HashSet<>(Collections.singletonList("GTPP_Decayables"));
@@ -23,32 +25,33 @@ public class GTPPRecipeProcessor implements IRecipeProcessor {
return identifiers;
}
@Nonnull
@Override
public String getRecipeProcessorId() {
return "GT++";
}
@Nonnull
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
List<PositionedStack> recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
recipeInputs.removeIf(positionedStack -> GregTech5RecipeProcessor.getFluidFromDisplayStack(positionedStack.items[0]) != null || positionedStack.item.stackSize == 0);
return recipeInputs;
}
List<PositionedStack> recipeInputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex));
recipeInputs.removeIf(positionedStack -> GregTech5RecipeProcessor.getFluidFromDisplayStack(positionedStack.items[0]) != null || positionedStack.item.stackSize == 0);
return recipeInputs;
}
return null;
return recipeInputs;
}
@Nonnull
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
List<PositionedStack> recipeOutputs = new ArrayList<>(recipe.getOtherStacks(recipeIndex));
recipeOutputs.removeIf(positionedStack -> GregTech5RecipeProcessor.getFluidFromDisplayStack(positionedStack.items[0]) != null);
return recipeOutputs;
}
List<PositionedStack> recipeOutputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex));
recipeOutputs.removeIf(positionedStack -> GregTech5RecipeProcessor.getFluidFromDisplayStack(positionedStack.items[0]) != null);
return recipeOutputs;
}
return null;
return recipeOutputs;
}
}
@@ -10,6 +10,7 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -35,6 +36,7 @@ public class GregTech5RecipeProcessor implements IRecipeProcessor {
gtAssLineClz = gtAL;
}
@Nonnull
@Override
public Set<String> getAllOverlayIdentifier() {
@@ -48,16 +50,18 @@ public class GregTech5RecipeProcessor implements IRecipeProcessor {
return identifiers;
}
@Nonnull
@Override
public String getRecipeProcessorId() {
return "GregTech5";
}
@Nonnull
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
List<PositionedStack> recipeInputs = new ArrayList<>();
if (gtDefaultClz.isInstance(recipe) || gtAssLineClz.isInstance(recipe)) {
List<PositionedStack> recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex));
recipeInputs.removeIf(positionedStack -> getFluidFromDisplayStack(positionedStack.items[0]) != null || positionedStack.item.stackSize == 0);
if (!recipeInputs.isEmpty()) {
ItemStack specialItem = recipeInputs.get(recipeInputs.size() - 1).items[0];
@@ -66,20 +70,22 @@ public class GregTech5RecipeProcessor implements IRecipeProcessor {
}
return recipeInputs;
}
return null;
return recipeInputs;
}
@Nonnull
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
List<PositionedStack> recipeOutputs = new ArrayList<>();
if (gtDefaultClz.isInstance(recipe) || gtAssLineClz.isInstance(recipe)) {
List<PositionedStack> recipeOutputs = new ArrayList<>(recipe.getOtherStacks(recipeIndex));
recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex));
recipeOutputs.removeIf(positionedStack -> getFluidFromDisplayStack(positionedStack.items[0]) != null);
//remove output if it's chance != 10000
recipeOutputs.removeIf(stack -> stack instanceof FixedPositionedStack && !(((FixedPositionedStack) stack).mChance == 10000 || ((FixedPositionedStack) stack).mChance <= 0));
return recipeOutputs;
}
return null;
return recipeOutputs;
}
/**
@@ -95,6 +101,7 @@ public class GregTech5RecipeProcessor implements IRecipeProcessor {
Fluid tFluid = FluidRegistry.getFluid(ItemList.Display_Fluid.getItem().getDamage(aDisplayStack));
return new FluidStack(tFluid, (int) aDisplayStack.getTagCompound().getLong("mFluidDisplayAmount"));
}
public static boolean isStackValid(Object aStack) {
return (aStack instanceof ItemStack) && ((ItemStack) aStack).getItem() != null && ((ItemStack) aStack).stackSize >= 0;
}
@@ -9,6 +9,7 @@ import gregapi.data.FL;
import gregapi.recipes.Recipe;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashSet;
@@ -19,6 +20,7 @@ import java.util.Set;
* @author vfyjxf
*/
public class GregTech6RecipeProcessor implements IRecipeProcessor {
@Nonnull
@Override
public Set<String> getAllOverlayIdentifier() {
Set<String> identifiers = new HashSet<>();
@@ -30,54 +32,55 @@ public class GregTech6RecipeProcessor implements IRecipeProcessor {
return identifiers;
}
@Nonnull
@Override
public String getRecipeProcessorId() {
return "GregTech6";
}
@Nonnull
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
List<PositionedStack> recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
//remove fluid
recipeInputs.removeIf(positionedStack -> FL.getFluid(positionedStack.item, true) != null || positionedStack.item.stackSize == 0);
//try to remove machine
if (recipe instanceof NEI_RecipeMap) {
Field mRecipeMapField = ReflectionHelper.findField(NEI_RecipeMap.class, "mRecipeMap");
Recipe.RecipeMap mRecipeMap = null;
try {
mRecipeMap = (Recipe.RecipeMap) mRecipeMapField.get(recipe);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
if (mRecipeMap != null) {
ItemStack lastItem = (recipeInputs.get(recipeInputs.size() - 1)).items[0];
for (ItemStack stack : mRecipeMap.mRecipeMachineList) {
if (ItemStack.areItemStackTagsEqual(lastItem, stack)) {
recipeInputs.remove(recipeInputs.size() - 1);
break;
}
List<PositionedStack> recipeInputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex));
//remove fluid
recipeInputs.removeIf(positionedStack -> FL.getFluid(positionedStack.item, true) != null || positionedStack.item.stackSize == 0);
//try to remove machine
if (recipe instanceof NEI_RecipeMap) {
Field mRecipeMapField = ReflectionHelper.findField(NEI_RecipeMap.class, "mRecipeMap");
Recipe.RecipeMap mRecipeMap = null;
try {
mRecipeMap = (Recipe.RecipeMap) mRecipeMapField.get(recipe);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
if (mRecipeMap != null) {
ItemStack lastItem = (recipeInputs.get(recipeInputs.size() - 1)).items[0];
for (ItemStack stack : mRecipeMap.mRecipeMachineList) {
if (ItemStack.areItemStackTagsEqual(lastItem, stack)) {
recipeInputs.remove(recipeInputs.size() - 1);
break;
}
}
}
return recipeInputs;
}
return recipeInputs;
}
return null;
return recipeInputs;
}
@Nonnull
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
List<PositionedStack> recipeOutput = new ArrayList<>(recipe.getOtherStacks(recipeIndex));
recipeOutput.removeIf(positionedStack -> FL.getFluid(positionedStack.item, true) != null || positionedStack.item.stackSize == 0);
//try to remove item output if it's chance != 100%
recipeOutput.removeIf(positionedStack -> positionedStack instanceof FixedPositionedStack && ((FixedPositionedStack) positionedStack).mChance > 0 && ((FixedPositionedStack) positionedStack).mChance != ((FixedPositionedStack) positionedStack).mMaxChance);
return recipeOutput;
}
List<PositionedStack> recipeOutput = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeOutput.addAll(recipe.getOtherStacks(recipeIndex));
recipeOutput.removeIf(positionedStack -> FL.getFluid(positionedStack.item, true) != null || positionedStack.item.stackSize == 0);
//try to remove item output if it's chance != 100%
recipeOutput.removeIf(positionedStack -> positionedStack instanceof FixedPositionedStack && ((FixedPositionedStack) positionedStack).mChance > 0 && ((FixedPositionedStack) positionedStack).mChance != ((FixedPositionedStack) positionedStack).mMaxChance);
return recipeOutput;
}
return null;
return recipeOutput;
}
}
@@ -3,12 +3,14 @@ package com.github.vfyjxf.nee.processor;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import javax.annotation.Nonnull;
import java.util.*;
/**
* @author vfyjxf
*/
public class ICRecipeProcessor implements IRecipeProcessor {
@Nonnull
@Override
public Set<String> getAllOverlayIdentifier() {
return new HashSet<>(Arrays.asList(
@@ -18,32 +20,33 @@ public class ICRecipeProcessor implements IRecipeProcessor {
));
}
@Nonnull
@Override
public String getRecipeProcessorId() {
return "IC2";
}
@Nonnull
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
return new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
}
List<PositionedStack> recipeInputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex));
return recipeInputs;
}
return null;
return recipeInputs;
}
@Nonnull
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
List<PositionedStack> recipeOutputs = new ArrayList<>();
recipeOutputs.add(recipe.getResultStack(recipeIndex));
recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex));
return recipeOutputs;
}
List<PositionedStack> recipeOutputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeOutputs.add(recipe.getResultStack(recipeIndex));
recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex));
return recipeOutputs;
}
return null;
return recipeOutputs;
}
@@ -3,6 +3,7 @@ package com.github.vfyjxf.nee.processor;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -12,15 +13,18 @@ import java.util.Set;
*/
public interface IRecipeProcessor {
@Nonnull
default Set<String> getAllOverlayIdentifier(){
return Collections.emptySet();
}
@Nonnull
String getRecipeProcessorId();
@Nonnull
List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier);
@Nonnull
List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier);
}
@@ -3,12 +3,14 @@ package com.github.vfyjxf.nee.processor;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import javax.annotation.Nonnull;
import java.util.*;
/**
* @author vfyjxf
*/
public class ImmersiveEngineeringRecipeProcessor implements IRecipeProcessor {
@Nonnull
@Override
public Set<String> getAllOverlayIdentifier() {
return new HashSet<>(Arrays.asList(
@@ -19,37 +21,37 @@ public class ImmersiveEngineeringRecipeProcessor implements IRecipeProcessor {
));
}
@Nonnull
@Override
public String getRecipeProcessorId() {
return "ImmersiveEngineering";
}
@Nonnull
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
List<PositionedStack> recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
if (!("ieArcFurnace".equals(identifier) || "ieCrusher".equals(identifier) || "ieBlastFurnace".equals(identifier))) {
recipeInputs.addAll(recipe.getOtherStacks(recipeIndex));
}
return recipeInputs;
List<PositionedStack> recipeInputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex));
if (!("ieArcFurnace".equals(identifier) || "ieCrusher".equals(identifier) || "ieBlastFurnace".equals(identifier))) {
recipeInputs.addAll(recipe.getOtherStacks(recipeIndex));
}
return recipeInputs;
}
return null;
return recipeInputs;
}
@Nonnull
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
List<PositionedStack> recipeOutputs = new ArrayList<>();
recipeOutputs.add(recipe.getResultStack(recipeIndex));
if ("ieArcFurnace".equals(identifier) || "ieCrusher".equals(identifier)) {
recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex));
}
return recipeOutputs;
List<PositionedStack> recipeOutputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeOutputs.add(recipe.getResultStack(recipeIndex));
if ("ieArcFurnace".equals(identifier) || "ieCrusher".equals(identifier)) {
recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex));
}
return recipeOutputs;
}
return null;
return recipeOutputs;
}
}
@@ -3,12 +3,14 @@ package com.github.vfyjxf.nee.processor;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import javax.annotation.Nonnull;
import java.util.*;
/**
* @author vfyjxf
*/
public class MekanismRecipeProcessor implements IRecipeProcessor {
@Nonnull
@Override
public Set<String> getAllOverlayIdentifier() {
return new HashSet<>(Arrays.asList(
@@ -19,34 +21,34 @@ public class MekanismRecipeProcessor implements IRecipeProcessor {
));
}
@Nonnull
@Override
public String getRecipeProcessorId() {
return "Mekanism";
}
@Nonnull
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
List<PositionedStack> recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
if (!recipe.getOtherStacks(recipeIndex).isEmpty()) {
recipeInputs.addAll(recipe.getOtherStacks(recipeIndex));
}
return recipeInputs;
List<PositionedStack> recipeInputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex));
if (!recipe.getOtherStacks(recipeIndex).isEmpty()) {
recipeInputs.addAll(recipe.getOtherStacks(recipeIndex));
}
return recipeInputs;
}
return null;
return recipeInputs;
}
@Nonnull
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
List<PositionedStack> recipeOutputs = new ArrayList<>();
recipeOutputs.add(recipe.getResultStack(recipeIndex));
return recipeOutputs;
}
List<PositionedStack> recipeOutputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeOutputs.add(recipe.getResultStack(recipeIndex));
return recipeOutputs;
}
return null;
return recipeOutputs;
}
}
@@ -46,23 +46,23 @@ public class RecipeProcessor {
NotEnoughEnergistics.logger.info("Found ThermalExpansion, install ThermalExpansion support");
recipeProcessors.add(new ThermalExpansionRecipeProcessor());
}
if(Loader.isModLoaded("ImmersiveEngineering")){
if (Loader.isModLoaded("ImmersiveEngineering")) {
NotEnoughEnergistics.logger.info("Found ImmersiveEngineering, install ImmersiveEngineering support");
recipeProcessors.add(new ImmersiveEngineeringRecipeProcessor());
}
if(Loader.isModLoaded("Mekanism")){
if (Loader.isModLoaded("Mekanism")) {
NotEnoughEnergistics.logger.info("Found Mekanism, install Mekanism support");
recipeProcessors.add(new MekanismRecipeProcessor());
}
if(Loader.isModLoaded("AWWayofTime")){
if (Loader.isModLoaded("AWWayofTime")) {
NotEnoughEnergistics.logger.info("Found BloodMagic, install BloodMagic support");
recipeProcessors.add(new BloodMagicRecipeProcessor());
}
if(Loader.isModLoaded("BuildCraft|Compat")){
if (Loader.isModLoaded("BuildCraft|Compat")) {
NotEnoughEnergistics.logger.info("Found BuildCraft-Compat, install BuildCraft-Compat support");
recipeProcessors.add(new BuildCraftRecipeProcessor());
}
if(Loader.isModLoaded("miscutils")){
if (Loader.isModLoaded("miscutils")) {
NotEnoughEnergistics.logger.info("Found GT++, install GT++ support");
recipeProcessors.add(new GTPPRecipeProcessor());
}
@@ -4,47 +4,49 @@ import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import com.djgiannuzz.thaumcraftneiplugin.items.ItemAspect;
import javax.annotation.Nonnull;
import java.util.*;
/**
* @author vfyjxf
*/
public class TCNEIPluginRecipeProcessor implements IRecipeProcessor{
public class TCNEIPluginRecipeProcessor implements IRecipeProcessor {
@Nonnull
@Override
public Set<String> getAllOverlayIdentifier() {
return new HashSet<>(Arrays.asList(
"arcaneshapedrecipes","arcaneshapelessrecipes","aspectsRecipe",
"cruciblerecipe","infusionCrafting"
"arcaneshapedrecipes", "arcaneshapelessrecipes", "aspectsRecipe",
"cruciblerecipe", "infusionCrafting"
));
}
@Nonnull
@Override
public String getRecipeProcessorId() {
return "TCNEIPlugin";
}
@Nonnull
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for(String ident : getAllOverlayIdentifier()){
if(ident.equals(identifier)){
List<PositionedStack> recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
recipeInputs.removeIf(positionedStack -> positionedStack.item.getItem() instanceof ItemAspect);
return recipeInputs;
}
List<PositionedStack> recipeInputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex));
recipeInputs.removeIf(positionedStack -> positionedStack.item.getItem() instanceof ItemAspect);
return recipeInputs;
}
return null;
return recipeInputs;
}
@Nonnull
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for(String ident : getAllOverlayIdentifier()){
if(ident.equals(identifier)){
List<PositionedStack> recipeOutputs = new ArrayList<>();
recipeOutputs.add(recipe.getResultStack(recipeIndex));
return recipeOutputs;
}
List<PositionedStack> recipeOutputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeOutputs.add(recipe.getResultStack(recipeIndex));
return recipeOutputs;
}
return null;
return recipeOutputs;
}
}
@@ -5,11 +5,14 @@ import codechicken.nei.recipe.IRecipeHandler;
import cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase;
import cpw.mods.fml.relauncher.ReflectionHelper;
import javax.annotation.Nonnull;
import java.lang.reflect.Field;
import java.util.*;
public class ThermalExpansionRecipeProcessor implements IRecipeProcessor {
@Nonnull
@Override
public Set<String> getAllOverlayIdentifier() {
return new HashSet<>(Arrays.asList(
@@ -18,75 +21,75 @@ public class ThermalExpansionRecipeProcessor implements IRecipeProcessor {
));
}
@Nonnull
@Override
public String getRecipeProcessorId() {
return "ThermalExpansion";
}
@Nonnull
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
List<PositionedStack> recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
if (recipe instanceof RecipeHandlerBase) {
Class<?> NEIRecipeBase = null;
List<PositionedStack> recipeInputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex));
if (recipe instanceof RecipeHandlerBase) {
Class<?> NEIRecipeBase = null;
try {
NEIRecipeBase = Class.forName("cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase$NEIRecipeBase");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
if (NEIRecipeBase != null) {
Field secondaryInputField = ReflectionHelper.findField(NEIRecipeBase, "secondaryInput");
PositionedStack secondaryInput = null;
try {
NEIRecipeBase = Class.forName("cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase$NEIRecipeBase");
} catch (ClassNotFoundException e) {
secondaryInput = (PositionedStack) secondaryInputField.get(((RecipeHandlerBase) recipe).arecipes.get(recipeIndex));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
if (NEIRecipeBase != null) {
Field secondaryInputField = ReflectionHelper.findField(NEIRecipeBase, "secondaryInput");
PositionedStack secondaryInput = null;
try {
secondaryInput = (PositionedStack) secondaryInputField.get(((RecipeHandlerBase) recipe).arecipes.get(recipeIndex));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
if (secondaryInput != null) {
recipeInputs.add(secondaryInput);
}
if (secondaryInput != null) {
recipeInputs.add(secondaryInput);
}
}
return recipeInputs;
}
return recipeInputs;
}
return null;
return recipeInputs;
}
@Nonnull
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
List<PositionedStack> recipeOutputs = new ArrayList<>();
recipeOutputs.add(recipe.getResultStack(recipeIndex));
if (recipe instanceof RecipeHandlerBase) {
Class<?> NEIRecipeBase = null;
List<PositionedStack> recipeOutputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeOutputs.add(recipe.getResultStack(recipeIndex));
if (recipe instanceof RecipeHandlerBase) {
Class<?> NEIRecipeBase = null;
try {
NEIRecipeBase = Class.forName("cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase$NEIRecipeBase");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
if (NEIRecipeBase != null) {
Field secondaryOutputField = ReflectionHelper.findField(NEIRecipeBase, "secondaryOutput");
Field secondaryOutputChanceField = ReflectionHelper.findField(NEIRecipeBase, "secondaryOutputChance");
PositionedStack secondaryOutput = null;
int secondaryOutputChance = 0;
try {
NEIRecipeBase = Class.forName("cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase$NEIRecipeBase");
} catch (ClassNotFoundException e) {
secondaryOutput = (PositionedStack) secondaryOutputField.get(((RecipeHandlerBase) recipe).arecipes.get(recipeIndex));
secondaryOutputChance = (int) secondaryOutputChanceField.get(((RecipeHandlerBase) recipe).arecipes.get(recipeIndex));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
if (NEIRecipeBase != null) {
Field secondaryOutputField = ReflectionHelper.findField(NEIRecipeBase, "secondaryOutput");
Field secondaryOutputChanceField = ReflectionHelper.findField(NEIRecipeBase, "secondaryOutputChance");
PositionedStack secondaryOutput = null;
int secondaryOutputChance = 0;
try {
secondaryOutput = (PositionedStack) secondaryOutputField.get(((RecipeHandlerBase) recipe).arecipes.get(recipeIndex));
secondaryOutputChance = (int) secondaryOutputChanceField.get(((RecipeHandlerBase) recipe).arecipes.get(recipeIndex));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
if (secondaryOutput != null && secondaryOutputChance >= 100) {
recipeOutputs.add(secondaryOutput);
}
if (secondaryOutput != null && secondaryOutputChance >= 100) {
recipeOutputs.add(secondaryOutput);
}
}
return recipeOutputs;
}
return recipeOutputs;
}
return null;
return recipeOutputs;
}
}
@@ -3,40 +3,45 @@ package com.github.vfyjxf.nee.processor;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import javax.annotation.Nonnull;
import java.util.*;
/**
* @author vfyjxf
*/
public class VanillaRecipeProcessor implements IRecipeProcessor {
@Nonnull
@Override
public Set<String> getAllOverlayIdentifier() {
return new HashSet<>(Arrays.asList("brewing", "smelting", "fuel"));
}
@Nonnull
@Override
public String getRecipeProcessorId() {
return "Vanilla";
}
@Nonnull
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
List<PositionedStack> recipeInputs = new ArrayList<>();
if ("brewing".equals(identifier) || "smelting".equals(identifier) || "fuel".equals(identifier)) {
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex));
recipeInputs.addAll(recipe.getOtherStacks(recipeIndex));
}
return recipeInputs;
}
@Nonnull
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
if ("brewing".equals(identifier) || "smelting".equals(identifier) || "fuel".equals(identifier)) {
List<PositionedStack> recipeOutput = new ArrayList<>();
List<PositionedStack> recipeOutput = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeOutput.add(recipe.getResultStack(recipeIndex));
return recipeOutput;
}
return null;
return recipeOutput;
}
}