Add gregtech 6 support

This commit is contained in:
vfyjxf committed 2021-08-12 22:11:45 +08:00
1 parent 23da96e1aa
commit a66fed83ed
9 files changed
+99 -12

No files matched your search

@@ -19,7 +19,7 @@ import java.util.Set;
/**
* @author vfyjxf
*/
public class GregTechRecipeProcessor implements IRecipeProcessor {
public class GregTech5RecipeProcessor implements IRecipeProcessor {
private static final Class<?> gtDefaultClz, gtAssLineClz;
@@ -0,0 +1,83 @@
package com.github.vfyjxf.nee.processor;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import cpw.mods.fml.relauncher.ReflectionHelper;
import gregapi.NEI_RecipeMap;
import gregapi.NEI_RecipeMap.FixedPositionedStack;
import gregapi.data.FL;
import gregapi.recipes.Recipe;
import net.minecraft.item.ItemStack;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @author vfyjxf
*/
public class GregTech6RecipeProcessor implements IRecipeProcessor {
@Override
public Set<String> getAllOverlayIdentifier() {
Set<String> identifiers = new HashSet<>();
for (Recipe.RecipeMap tMap : Recipe.RecipeMap.RECIPE_MAPS.values()) {
if (tMap.mNEIAllowed) {
identifiers.add(tMap.mNameNEI);
}
}
return identifiers;
}
@Override
public String getRecipeProcessorId() {
return "GregTech6";
}
@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;
}
}
}
}
return recipeInputs;
}
}
return null;
}
@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;
}
}
return null;
}
}
@@ -14,9 +14,13 @@ public class RecipeProcessor {
NotEnoughEnergistics.logger.info("Install Vanilla Support");
recipeProcessors.add(new VanillaRecipeProcessor());
if (Loader.isModLoaded("gregtech")) {
NotEnoughEnergistics.logger.info("Found GregTech,install GregTech support");
recipeProcessors.add(new GregTechRecipeProcessor());
if (Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi")) {
NotEnoughEnergistics.logger.info("Found GregTech5,install GregTech5 support");
recipeProcessors.add(new GregTech5RecipeProcessor());
}
if (Loader.isModLoaded("gregapi") && Loader.isModLoaded("gregapi_post")) {
NotEnoughEnergistics.logger.info("Found GregTech6,install GregTech6 support");
recipeProcessors.add(new GregTech6RecipeProcessor());
}
if (Loader.isModLoaded("IC2")) {
NotEnoughEnergistics.logger.info("Found IC2,install IC2 Support");
@@ -26,15 +30,15 @@ public class RecipeProcessor {
NotEnoughEnergistics.logger.info("Found Avaritia, install Avaritia support");
recipeProcessors.add(new AvaritiaRecipeProcessor());
}
if(Loader.isModLoaded("EnderIO")){
if (Loader.isModLoaded("EnderIO")) {
NotEnoughEnergistics.logger.info("Found EnderIO, install EnderIO support");
recipeProcessors.add(new EnderIORecipeProcessor());
}
if(Loader.isModLoaded("Forestry")){
if (Loader.isModLoaded("Forestry")) {
NotEnoughEnergistics.logger.info("Found Forestry, install Forestry support");
recipeProcessors.add(new ForestryRecipeProcessor());
}
if(Loader.isModLoaded("thaumcraftneiplugin")){
if (Loader.isModLoaded("thaumcraftneiplugin")) {
NotEnoughEnergistics.logger.info("Found TCNEIPlugin, install TCNEIPlugin support");
recipeProcessors.add(new TCNEIPluginRecipeProcessor());
}