diff --git a/README.md b/README.md index aa31877..61d4e08 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ This mod removes that functionality and allows the player to use NEI's transfer - [x] EnderIO - [x] Forestry(Doesn't support Fermenter and Still,because they don't have an item output) -If you want other Mod support,see [RecipeProcessor](./src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java) and [Mod support](https://github.com/vfyjxf/NotEnoughEnergistics/issues/1) +If you want other Mod support,see [RecipeProcessor](./src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java) and [Mod support Issue](https://github.com/vfyjxf/NotEnoughEnergistics/issues/1) ## TODO @@ -36,4 +36,4 @@ If you want other Mod support,see [RecipeProcessor](./src/main/java/com/github/v ~~Combine like stacks in processing patterns.~~ ## Credits -Thanks TheRealp455w0rd and his [Just Enough Energistics](https://www.curseforge.com/minecraft/mc-mods/just-enough-energistics-jee) +Thanks TheRealp455w0rd and his [Just Enough Energistics](https://www.curseforge.com/minecraft/mc-mods/just-enough-energistics-jee) \ No newline at end of file diff --git a/READNE_CN.md b/READNE_CN.md index e9ff86e..fa9a88d 100644 --- a/READNE_CN.md +++ b/READNE_CN.md @@ -4,20 +4,30 @@ NotEnoughEnergistics 是[Just Enough Energistics](https://www.curseforge.com/min 它替换了AE2默认的NEI集成, 默认情况下ae只能识别玩家身上或者网络里的存储物品。 本MOD允许你直接从nei获取配方并写入样板终端(shift点击[?]按钮) -并且会自动帮你切换样板模式。 + +## Features + +- 根据配方自动切换样板终端的模式 +- 如果一个物品输出为概率输出,那么NEE不会将它写入样板终端 +- 在处理模式中合并同类物品 ## 当前支持的Mod列表: + +- [ ] AppliedEnergistics2(我们将不会支持AE2,因为AE2没有注册对应的OverlayHandler) - [x] Vanilla - [x] GregTech - [x] IndustrialCraft2 - [x] Avaritia +- [x] EnderIO +- [x] Forestry(不支持发酵机和蒸馏器,因为它们没有物品输出) 如果你想要别的Mod的支持,请看[RecipeProcessor](./src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java) 或者[模组支持处理区](https://github.com/vfyjxf/NotEnoughEnergistics/issues/1) ## TODO - 添加转换黑名单,使在黑名单里的物品不会被转移到样板终端 - 添加优先转换列表,在优先转换列表的物品会替换配方里的同类物品 - - 在有多个同类物品的情况下,合并同类物品 + + ~~在有多个同类物品的情况下,合并同类物品~~ ## Credits 感谢 TheRealp455w0rd 和他的 [Just Enough Energistics](https://www.curseforge.com/minecraft/mc-mods/just-enough-energistics-jee) diff --git a/build.gradle b/build.gradle index 76f06fe..eb8eab3 100644 --- a/build.gradle +++ b/build.gradle @@ -8,13 +8,12 @@ buildscript { } } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-1.4.0-SNAPSHOT' + classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-1.4.4-SNAPSHOT' } } apply plugin: 'java' apply plugin: 'forge' - [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' @@ -44,9 +43,6 @@ dependencies { compile "codechicken:CodeChickenLib:1.7.10-1.1.3.138:dev" compile "codechicken:CodeChickenCore:1.7.10-1.0.7.+:dev" -// https://mvnrepository.com/artifact/com.alibaba/fastjson - implementation group: 'com.alibaba', name: 'fastjson', version: '1.2.76' - } processResources { @@ -59,7 +55,8 @@ processResources { 'mod_author': mod_author, 'mod_description': mod_description, 'mc_version': mc_version, - 'mod_version': mod_version + 'mod_version': mod_version, + 'mod_credits': mod_credits } from(sourceSets.main.resources.srcDirs) { @@ -85,4 +82,4 @@ jar{ artifacts { archives devJar archives sourcesJar -} +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index c4793ed..b79aa0a 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.0.0 +mod_version=1.1.0 forge_version=10.13.4.1614 mod_group=com.github.vfyjxf.neenergistics mod_id=neenergistics diff --git a/src/main/java/com/github/vfyjxf/nee/NEINeeConfig.java b/src/main/java/com/github/vfyjxf/nee/NEINeeConfig.java index 62df4b8..acc7f81 100644 --- a/src/main/java/com/github/vfyjxf/nee/NEINeeConfig.java +++ b/src/main/java/com/github/vfyjxf/nee/NEINeeConfig.java @@ -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 defaultIdentifiers= Arrays.asList("crafting", "crafting2x2","brewing","smelting","fuel"); - List identifiers = new ArrayList<>(defaultIdentifiers); + Set defaultIdentifiers= new HashSet<>( + Arrays.asList("crafting", "crafting2x2","brewing","smelting","fuel",null) + ); + Set identifiers = new HashSet<>(defaultIdentifiers); for(IRecipeProcessor processor : RecipeProcessor.recipeProcessors){ identifiers.addAll(processor.getAllOverlayIdentifier()); diff --git a/src/main/java/com/github/vfyjxf/nee/nei/NEECraftingHandler.java b/src/main/java/com/github/vfyjxf/nee/nei/NEECraftingHandler.java index 835b680..97cde55 100644 --- a/src/main/java/com/github/vfyjxf/nee/nei/NEECraftingHandler.java +++ b/src/main/java/com/github/vfyjxf/nee/nei/NEECraftingHandler.java @@ -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())); diff --git a/src/main/java/com/github/vfyjxf/nee/processor/AvaritiaRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/AvaritiaRecipeProcessor.java index 2eb2f5f..ef23451 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/AvaritiaRecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/AvaritiaRecipeProcessor.java @@ -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 getAllOverlayIdentifier() { return new HashSet<>(Arrays.asList( - "extreme","extreme_compression" + "extreme", "extreme_compression" )); } @Override public List 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 getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for(String ident : getAllOverlayIdentifier()){ - if(ident.equals(identifier)){ + for (String ident : getAllOverlayIdentifier()) { + if (ident.equals(identifier)) { List recipeOutput = new ArrayList<>(); recipeOutput.add(recipe.getResultStack(recipeIndex)); return recipeOutput; diff --git a/src/main/java/com/github/vfyjxf/nee/processor/EnderIORecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/EnderIORecipeProcessor.java new file mode 100644 index 0000000..0cb667d --- /dev/null +++ b/src/main/java/com/github/vfyjxf/nee/processor/EnderIORecipeProcessor.java @@ -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 getAllOverlayIdentifier() { + return new HashSet<>(Arrays.asList( + "EnderIOAlloySmelter", "EIOEnchanter", "EnderIOSagMill", + "EnderIOSliceAndSplice", "EnderIOSoulBinder", "EnderIOVat" + )); + } + + @Override + public List 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 getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { + if(identifier!=null) { + for (String ident : getAllOverlayIdentifier()) { + if (ident.equals(identifier)) { + List 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; + } +} diff --git a/src/main/java/com/github/vfyjxf/nee/processor/ForestryRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/ForestryRecipeProcessor.java new file mode 100644 index 0000000..26305d7 --- /dev/null +++ b/src/main/java/com/github/vfyjxf/nee/processor/ForestryRecipeProcessor.java @@ -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 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 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 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 has a 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 + +} diff --git a/src/main/java/com/github/vfyjxf/nee/processor/GregTechRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/GregTechRecipeProcessor.java index 0ae51b1..3b7c6ea 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/GregTechRecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/GregTechRecipeProcessor.java @@ -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 getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) { + if (gtDefaultClz.isInstance(recipe) || gtAssLineClz.isInstance(recipe)) { List 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 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; diff --git a/src/main/java/com/github/vfyjxf/nee/processor/ICRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/ICRecipeProcessor.java index c1b979e..8b4eebd 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/ICRecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/ICRecipeProcessor.java @@ -20,7 +20,7 @@ public class ICRecipeProcessor implements IRecipeProcessor { @Override public List 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 getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { for (String ident : getAllOverlayIdentifier()) { - if (identifier.equals(ident)) { + if (ident.equals(identifier)) { List recipeOutputs = new ArrayList<>(); recipeOutputs.add(recipe.getResultStack(recipeIndex)); recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex)); 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 2176695..c9bbc8f 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java @@ -9,22 +9,34 @@ import java.util.List; public class RecipeProcessor { public static List 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-----"); } diff --git a/src/main/java/com/github/vfyjxf/nee/processor/VanillaRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/VanillaRecipeProcessor.java index 3f11409..b083459 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/VanillaRecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/VanillaRecipeProcessor.java @@ -34,5 +34,4 @@ public class VanillaRecipeProcessor implements IRecipeProcessor { return null; } - } diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index d05eaa7..89e0fa7 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -7,7 +7,7 @@ "url": "", "updateUrl": "", "authorList": ["${mod_author}"], - "credits": "", + "credits": "${mod_credits}", "screenshots": [], "dependencies": [] -}] \ No newline at end of file +}]