diff --git a/README.md b/README.md index 4876e87..a9de036 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,8 @@ This mod removes that functionality and allows the player to use NEI's transfer - [ ] AppliedEnergistics2(Won't support it because AE2 doesn't register OverlayHandler) - [x] Vanilla -- [x] GregTech +- [x] GregTech5 +- [x] GregTech6 - [x] IndustrialCraft2 - [x] Avaritia - [x] EnderIO diff --git a/READNE_CN.md b/READNE_CN.md index 329e8bc..dbd9891 100644 --- a/READNE_CN.md +++ b/READNE_CN.md @@ -16,7 +16,8 @@ NotEnoughEnergistics 是[Just Enough Energistics](https://www.curseforge.com/min - [ ] AppliedEnergistics2(我们将不会支持AE2,因为AE2没有注册对应的OverlayHandler) - [x] Vanilla -- [x] GregTech +- [x] GregTech5 +- [x] GregTech6 - [x] IndustrialCraft2 - [x] Avaritia - [x] EnderIO diff --git a/build.gradle b/build.gradle index 1d1ed58..d799c1c 100644 --- a/build.gradle +++ b/build.gradle @@ -55,8 +55,6 @@ dependencies { compile "codechicken:CodeChickenLib:1.7.10-1.1.3.138:dev" compile "codechicken:CodeChickenCore:1.7.10-1.0.7.+:dev" - runtime "thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev" - } processResources { diff --git a/gradle.properties b/gradle.properties index 00ef3c6..dc2fd3a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.daemon=false mc_version=1.7.10 nei_version=2.1.6-GTNH ae2_version=rv3-beta-52-GTNH -mod_version=1.2.0 +mod_version=1.2.1 forge_version=10.13.4.1614 mod_group=com.github.vfyjxf.neenergistics mod_id=neenergistics diff --git a/libs/gregtech_1.7.10-6.14.20-dev.jar b/libs/gregtech_1.7.10-6.14.20-dev.jar new file mode 100644 index 0000000..39bef90 Binary files /dev/null and b/libs/gregtech_1.7.10-6.14.20-dev.jar differ diff --git a/libs/gregtech_1.7.10-6.14.20-sources.jar b/libs/gregtech_1.7.10-6.14.20-sources.jar new file mode 100644 index 0000000..b8bb03e Binary files /dev/null and b/libs/gregtech_1.7.10-6.14.20-sources.jar differ diff --git a/src/main/java/com/github/vfyjxf/nee/processor/GregTechRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/GregTech5RecipeProcessor.java similarity index 98% rename from src/main/java/com/github/vfyjxf/nee/processor/GregTechRecipeProcessor.java rename to src/main/java/com/github/vfyjxf/nee/processor/GregTech5RecipeProcessor.java index e260b4e..5aa1101 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/GregTechRecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/GregTech5RecipeProcessor.java @@ -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; diff --git a/src/main/java/com/github/vfyjxf/nee/processor/GregTech6RecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/GregTech6RecipeProcessor.java new file mode 100644 index 0000000..afc2d71 --- /dev/null +++ b/src/main/java/com/github/vfyjxf/nee/processor/GregTech6RecipeProcessor.java @@ -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 getAllOverlayIdentifier() { + Set 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 getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) { + for (String ident : getAllOverlayIdentifier()) { + if (ident.equals(identifier)) { + List 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 getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { + for (String ident : getAllOverlayIdentifier()) { + if (ident.equals(identifier)) { + List 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; + } +} diff --git a/src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java index 4cf494b..5e41001 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java @@ -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()); }