Updata EnderIO support and Forestry support

This commit is contained in:
vfyjxf committed 2021-08-07 19:34:52 +08:00
1 parent a69878864f
commit 1449d88915
14 files changed
+209 -40

No files matched your search

@@ -8,9 +8,7 @@ import com.github.vfyjxf.nee.nei.NEECraftingHandler;
import com.github.vfyjxf.nee.processor.IRecipeProcessor;
import com.github.vfyjxf.nee.processor.RecipeProcessor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;
public class NEINeeConfig implements IConfigureNEI {
@@ -20,8 +18,10 @@ public class NEINeeConfig implements IConfigureNEI {
RecipeProcessor.init();
List<String> defaultIdentifiers= Arrays.asList("crafting", "crafting2x2","brewing","smelting","fuel");
List<String> identifiers = new ArrayList<>(defaultIdentifiers);
Set<String> defaultIdentifiers= new HashSet<>(
Arrays.asList("crafting", "crafting2x2","brewing","smelting","fuel",null)
);
Set<String> identifiers = new HashSet<>(defaultIdentifiers);
for(IRecipeProcessor processor : RecipeProcessor.recipeProcessors){
identifiers.addAll(processor.getAllOverlayIdentifier());
@@ -84,7 +84,7 @@ public class NEECraftingHandler implements IOverlayHandler {
}
for (PositionedStack positionedStack : outputs) {
if (outputIndex >= 4 || positionedStack.item == null) {
if (outputIndex >= 4 ||positionedStack == null || positionedStack.item == null) {
continue;
}
recipeOutputs.setTag(OUTPUT_KEY + outputIndex, positionedStack.item.writeToNBT(new NBTTagCompound()));
@@ -5,18 +5,18 @@ import codechicken.nei.recipe.IRecipeHandler;
import java.util.*;
public class AvaritiaRecipeProcessor implements IRecipeProcessor{
public class AvaritiaRecipeProcessor implements IRecipeProcessor {
@Override
public Set<String> getAllOverlayIdentifier() {
return new HashSet<>(Arrays.asList(
"extreme","extreme_compression"
"extreme", "extreme_compression"
));
}
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for(String ident : getAllOverlayIdentifier()){
if(ident.equals(identifier)){
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
return new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
}
}
@@ -25,8 +25,8 @@ public class AvaritiaRecipeProcessor implements IRecipeProcessor{
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for(String ident : getAllOverlayIdentifier()){
if(ident.equals(identifier)){
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
List<PositionedStack> recipeOutput = new ArrayList<>();
recipeOutput.add(recipe.getResultStack(recipeIndex));
return recipeOutput;
@@ -0,0 +1,47 @@
package com.github.vfyjxf.nee.processor;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import crazypants.enderio.nei.SagMillRecipeHandler;
import java.util.*;
public class EnderIORecipeProcessor implements IRecipeProcessor {
@Override
public Set<String> getAllOverlayIdentifier() {
return new HashSet<>(Arrays.asList(
"EnderIOAlloySmelter", "EIOEnchanter", "EnderIOSagMill",
"EnderIOSliceAndSplice", "EnderIOSoulBinder", "EnderIOVat"
));
}
@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;
}
@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;
}
}
}
return null;
}
}
@@ -0,0 +1,104 @@
package com.github.vfyjxf.nee.processor;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import forestry.factory.recipes.nei.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ForestryRecipeProcessor implements IRecipeProcessor {
@Override
public List<PositionedStack> 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);
}
return null;
}
@Override
public List<PositionedStack> 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);
}
return null;
}
private List<PositionedStack> bottlerHandler(NEIHandlerBottler base, int recipeIndex, boolean getInput) {
return getInput ? base.getIngredientStacks(recipeIndex) : Collections.singletonList(base.getResultStack(recipeIndex));
}
private List<PositionedStack> carpenterHandler(NEIHandlerCarpenter base, int recipeIndex, boolean getInput) {
return getInput ? base.getIngredientStacks(recipeIndex) : Collections.singletonList(base.getResultStack(recipeIndex));
}
private List<PositionedStack> centrifugeHandler(NEIHandlerCentrifuge base, int recipeIndex, boolean getInput) {
return getInput ? base.getIngredientStacks(recipeIndex) : base.getOtherStacks(recipeIndex);
}
private List<PositionedStack> fabricatorHandler(NEIHandlerFabricator base, int recipeIndex, boolean getInput) {
List<PositionedStack> 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 has a item output
private List<PositionedStack> moistenerHandler(NEIHandlerMoistener base, int recipeIndex, boolean getInput) {
List<PositionedStack> recipeInput = new ArrayList<>(base.getIngredientStacks(recipeIndex));
recipeInput.addAll(base.getOtherStacks(recipeIndex));
return getInput ? recipeInput : Collections.singletonList(base.getResultStack(recipeIndex));
}
private List<PositionedStack> squeezerHandler(NEIHandlerSqueezer base, int recipeIndex, boolean getInput) {
return getInput ? base.getIngredientStacks(recipeIndex) : Collections.singletonList(base.getResultStack(recipeIndex));
}
//Still doesn't need support
}
@@ -2,13 +2,9 @@ package com.github.vfyjxf.nee.processor;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import gregtech.api.enums.ItemList;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import gregtech.nei.GT_NEI_DefaultHandler.FixedPositionedStack;
import java.util.ArrayList;
import java.util.HashSet;
@@ -50,12 +46,14 @@ public class GregTechRecipeProcessor implements IRecipeProcessor {
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
if (gtDefaultClz.isInstance(recipe) || gtAssLineClz.isInstance(recipe)) {
List<PositionedStack> recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
recipeInputs.removeIf(positionedStack -> GT_Utility.getFluidFromDisplayStack(positionedStack.items[0]) != null || positionedStack.item.stackSize == 0);
return recipeInputs;
}
return null;
}
@Override
@@ -63,6 +61,8 @@ public class GregTechRecipeProcessor implements IRecipeProcessor {
if (gtDefaultClz.isInstance(recipe) || gtAssLineClz.isInstance(recipe)) {
List<PositionedStack> recipeOutputs = new ArrayList<>(recipe.getOtherStacks(recipeIndex));
recipeOutputs.removeIf(positionedStack -> GT_Utility.getFluidFromDisplayStack(positionedStack.items[0]) != null);
//remove output if it's chance != 1
recipeOutputs.removeIf(stack -> stack instanceof FixedPositionedStack && !(((FixedPositionedStack) stack).mChance == 10000 || ((FixedPositionedStack) stack).mChance <= 0));
return recipeOutputs;
}
return null;
@@ -20,7 +20,7 @@ public class ICRecipeProcessor implements IRecipeProcessor {
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (identifier.equals(ident)) {
if (ident.equals(identifier)) {
return new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
}
}
@@ -30,7 +30,7 @@ public class ICRecipeProcessor implements IRecipeProcessor {
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (identifier.equals(ident)) {
if (ident.equals(identifier)) {
List<PositionedStack> recipeOutputs = new ArrayList<>();
recipeOutputs.add(recipe.getResultStack(recipeIndex));
recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex));
@@ -9,22 +9,34 @@ import java.util.List;
public class RecipeProcessor {
public static List<IRecipeProcessor> recipeProcessors = new ArrayList<>();
public static void init(){
public static void init() {
NotEnoughEnergistics.logger.info("-----Not Enough Energistics Init Start-----");
NotEnoughEnergistics.logger.info("Install Vanilla Support");
recipeProcessors.add(new VanillaRecipeProcessor());
if(Loader.isModLoaded("gregtech")){
NotEnoughEnergistics.logger.info("Found GregTech,install GregTech Support");
if (Loader.isModLoaded("gregtech")) {
NotEnoughEnergistics.logger.info("Found GregTech,install GregTech support");
recipeProcessors.add(new GregTechRecipeProcessor());
}
if(Loader.isModLoaded("IC2")){
if (Loader.isModLoaded("IC2")) {
NotEnoughEnergistics.logger.info("Found IC2,install IC2 Support");
recipeProcessors.add(new ICRecipeProcessor());
}
if(Loader.isModLoaded("Avaritia")){
NotEnoughEnergistics.logger.info("Found Avaritia, install Avaritia Support");
if (Loader.isModLoaded("Avaritia")) {
NotEnoughEnergistics.logger.info("Found Avaritia, install Avaritia support");
recipeProcessors.add(new AvaritiaRecipeProcessor());
}
if(Loader.isModLoaded("EnderIO")){
NotEnoughEnergistics.logger.info("Found EnderIO, install EnderIO support");
recipeProcessors.add(new EnderIORecipeProcessor());
}
if(Loader.isModLoaded("Forestry")){
NotEnoughEnergistics.logger.info("Found Forestry, install Forestry support");
recipeProcessors.add(new ForestryRecipeProcessor());
}
if (Loader.isModLoaded("appliedenergistics2")) {
NotEnoughEnergistics.logger.info("Applied Energistics 2 will not be supported");
}
NotEnoughEnergistics.logger.info("-----Not Enough Energistics Init Finished-----");
}
@@ -34,5 +34,4 @@ public class VanillaRecipeProcessor implements IRecipeProcessor {
return null;
}
}