diff --git a/dependencies.gradle b/dependencies.gradle index 6bf5b74f..f1c5f00a 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -5,7 +5,7 @@ dependencies { compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-87-GTNH:dev') compile('curse.maven:cofh-core-69162:2388751') compile('com.github.GTNewHorizons:ExtraCells2:2.5.9:dev') {transitive = false} - compile("com.github.GTNewHorizons:ForestryMC:4.4.4:dev") + compile("com.github.GTNewHorizons:ForestryMC:4.4.7:dev") compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.27:dev") compileOnly("com.github.GTNewHorizons:EnderCore:0.2.6:dev") @@ -15,4 +15,5 @@ dependencies { compileOnly('com.github.GTNewHorizons:AppleCore:3.1.9:dev') {transitive = false} compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.27:dev') {transitive = false} compileOnly("com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev") {transitive = false} + compileOnly("com.github.GTNewHorizons:GTplusplus:1.7.49:dev") {transitive = false} } diff --git a/src/main/java/com/glodblock/github/nei/recipes/DefaultExtractorLoader.java b/src/main/java/com/glodblock/github/nei/recipes/DefaultExtractorLoader.java index 9b0a1540..ee98d920 100644 --- a/src/main/java/com/glodblock/github/nei/recipes/DefaultExtractorLoader.java +++ b/src/main/java/com/glodblock/github/nei/recipes/DefaultExtractorLoader.java @@ -4,6 +4,7 @@ import com.glodblock.github.nei.recipes.extractor.*; import com.glodblock.github.util.ModAndClassUtil; import forestry.factory.recipes.nei.*; import gregapi.recipes.Recipe; +import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Recipe; public class DefaultExtractorLoader implements Runnable { @@ -27,6 +28,14 @@ public class DefaultExtractorLoader implements Runnable { } } + if (ModAndClassUtil.GTPP) { + for (GTPP_Recipe.GTPP_Recipe_Map_Internal gtppMap : GTPP_Recipe.GTPP_Recipe_Map_Internal.sMappingsEx) { + if (gtppMap.mNEIAllowed) { + FluidRecipe.addRecipeMap(gtppMap.mNEIName, new GTPPRecipeExtractor()); + } + } + } + if (ModAndClassUtil.EIO) { FluidRecipe.addRecipeMap("EIOEnchanter", new EnderIORecipeExtractor()); FluidRecipe.addRecipeMap("EnderIOAlloySmelter", new EnderIORecipeExtractor()); @@ -37,6 +46,17 @@ public class DefaultExtractorLoader implements Runnable { } if (ModAndClassUtil.FTR) { + // GTNH + FluidRecipe.addRecipeMap("forestry.bottler", new ForestryRecipeExtractor(new NEIHandlerBottler())); + FluidRecipe.addRecipeMap("forestry.carpenter", new ForestryRecipeExtractor(new NEIHandlerCarpenter())); + FluidRecipe.addRecipeMap("forestry.centrifuge", new ForestryRecipeExtractor(new NEIHandlerCentrifuge())); + FluidRecipe.addRecipeMap("forestry.fabricator", new ForestryRecipeExtractor(new NEIHandlerFabricator())); + FluidRecipe.addRecipeMap("forestry.fermenter", new ForestryRecipeExtractor(new NEIHandlerFermenter())); + FluidRecipe.addRecipeMap("forestry.moistener", new ForestryRecipeExtractor(new NEIHandlerMoistener())); + FluidRecipe.addRecipeMap("forestry.squeezer", new ForestryRecipeExtractor(new NEIHandlerSqueezer())); + FluidRecipe.addRecipeMap("forestry.still", new ForestryRecipeExtractor(new NEIHandlerStill())); + + // LEGACY FluidRecipe.addRecipeMap(null, new ForestryRecipeExtractor(new NEIHandlerBottler())); FluidRecipe.addRecipeMap(null, new ForestryRecipeExtractor(new NEIHandlerCarpenter())); FluidRecipe.addRecipeMap(null, new ForestryRecipeExtractor(new NEIHandlerCentrifuge())); diff --git a/src/main/java/com/glodblock/github/nei/recipes/extractor/ForestryRecipeExtractor.java b/src/main/java/com/glodblock/github/nei/recipes/extractor/ForestryRecipeExtractor.java index d8f7d3c1..d57a1feb 100644 --- a/src/main/java/com/glodblock/github/nei/recipes/extractor/ForestryRecipeExtractor.java +++ b/src/main/java/com/glodblock/github/nei/recipes/extractor/ForestryRecipeExtractor.java @@ -5,19 +5,16 @@ import codechicken.nei.recipe.IRecipeHandler; import codechicken.nei.recipe.TemplateRecipeHandler; import com.glodblock.github.nei.object.IRecipeExtractorLegacy; import com.glodblock.github.nei.object.OrderStack; -import crazypants.enderio.nei.VatRecipeHandler; +import com.glodblock.github.util.NEIUtil; import forestry.core.recipes.nei.PositionedFluidTank; import forestry.core.recipes.nei.RecipeHandlerBase; import forestry.factory.recipes.nei.NEIHandlerFabricator; import forestry.factory.recipes.nei.NEIHandlerSqueezer; -import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; public class ForestryRecipeExtractor implements IRecipeExtractorLegacy { @@ -58,7 +55,7 @@ public class ForestryRecipeExtractor implements IRecipeExtractorLegacy { public List> getInputIngredients(List rawInputs, IRecipeHandler recipe, int index) { TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe; List> tmp = new ArrayList<>(); - List compressed = compress(rawInputs); + List compressed = NEIUtil.compress(rawInputs); if (tRecipe.arecipes.get(index) instanceof RecipeHandlerBase.CachedBaseRecipe) { tmp = getInputIngredients(compressed); List tanks = ((RecipeHandlerBase.CachedBaseRecipe) tRecipe.arecipes.get(index)).getFluidTanks(); @@ -77,7 +74,7 @@ public class ForestryRecipeExtractor implements IRecipeExtractorLegacy { TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe; removeGlass(rawOutputs); List> tmp = new ArrayList<>(); - List compressed = compress(rawOutputs); + List compressed = NEIUtil.compress(rawOutputs); if (tRecipe.arecipes.get(index) instanceof RecipeHandlerBase.CachedBaseRecipe) { tmp = getOutputIngredients(compressed); List tanks = ((RecipeHandlerBase.CachedBaseRecipe) tRecipe.arecipes.get(index)).getFluidTanks(); @@ -97,29 +94,6 @@ public class ForestryRecipeExtractor implements IRecipeExtractorLegacy { return tmp; } - private List compress(List list) { - List comp = new LinkedList<>(); - for (PositionedStack positionedStack : list) { - if (positionedStack == null) continue; - ItemStack currentStack = positionedStack.items[0].copy(); - if (currentStack.stackSize == 0) continue; - boolean find = false; - for (PositionedStack storedStack : comp) { - if (storedStack == null) continue; - ItemStack firstStack = storedStack.items[0].copy(); - boolean areItemStackEqual = firstStack.isItemEqual(currentStack) && ItemStack.areItemStackTagsEqual(firstStack, currentStack); - if (areItemStackEqual && (firstStack.stackSize + currentStack.stackSize) <= firstStack.getMaxStackSize()) { - find = true; - storedStack.items[0].stackSize = firstStack.stackSize + currentStack.stackSize; - } - } - if (!find) { - comp.add(positionedStack.copy()); - } - } - return comp.stream().filter(Objects::nonNull).collect(Collectors.toList()); - } - private void removeGlass(List list) { if (handler instanceof NEIHandlerFabricator) { list.remove(list.size() - 1); diff --git a/src/main/java/com/glodblock/github/nei/recipes/extractor/GTPPRecipeExtractor.java b/src/main/java/com/glodblock/github/nei/recipes/extractor/GTPPRecipeExtractor.java new file mode 100644 index 00000000..56149a46 --- /dev/null +++ b/src/main/java/com/glodblock/github/nei/recipes/extractor/GTPPRecipeExtractor.java @@ -0,0 +1,13 @@ +package com.glodblock.github.nei.recipes.extractor; + +public class GTPPRecipeExtractor extends GregTech5RecipeExtractor { + + public GTPPRecipeExtractor() { + super(false); + } + + public GTPPRecipeExtractor(boolean removeSpecial) { + super(removeSpecial); + } + +} diff --git a/src/main/java/com/glodblock/github/nei/recipes/extractor/GregTech5RecipeExtractor.java b/src/main/java/com/glodblock/github/nei/recipes/extractor/GregTech5RecipeExtractor.java index 5cfe7e16..0351cf26 100644 --- a/src/main/java/com/glodblock/github/nei/recipes/extractor/GregTech5RecipeExtractor.java +++ b/src/main/java/com/glodblock/github/nei/recipes/extractor/GregTech5RecipeExtractor.java @@ -3,6 +3,7 @@ package com.glodblock.github.nei.recipes.extractor; import codechicken.nei.PositionedStack; import com.glodblock.github.nei.object.IRecipeExtractor; import com.glodblock.github.nei.object.OrderStack; +import com.glodblock.github.util.NEIUtil; import gregtech.api.enums.ItemList; import gregtech.common.items.GT_FluidDisplayItem; import net.minecraft.item.ItemStack; @@ -12,21 +13,19 @@ import net.minecraftforge.fluids.FluidStack; import java.util.LinkedList; import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; public class GregTech5RecipeExtractor implements IRecipeExtractor { - boolean r; + boolean removeSpecial; public GregTech5RecipeExtractor(boolean removeSpecial) { - r = removeSpecial; + this.removeSpecial = removeSpecial; } @Override public List> getInputIngredients(List rawInputs) { - if (r) removeSpecial(rawInputs); - List compressed = compress(rawInputs); + if (removeSpecial) removeSpecial(rawInputs); + List compressed = NEIUtil.compress(rawInputs); List> tmp = new LinkedList<>(); for (int i = 0; i < compressed.size(); i ++) { if (compressed.get(i) == null) continue; @@ -48,7 +47,7 @@ public class GregTech5RecipeExtractor implements IRecipeExtractor { @Override public List> getOutputIngredients(List rawOutputs) { - List compressed = compress(rawOutputs); + List compressed = NEIUtil.compress(rawOutputs); List> tmp = new LinkedList<>(); for (int i = 0; i < compressed.size(); i ++) { if (compressed.get(i) == null) continue; @@ -79,27 +78,4 @@ public class GregTech5RecipeExtractor implements IRecipeExtractor { } } - private List compress(List list) { - List comp = new LinkedList<>(); - for (PositionedStack positionedStack : list) { - if (positionedStack == null) continue; - ItemStack currentStack = positionedStack.items[0].copy(); - if (currentStack.stackSize == 0) continue; - boolean find = false; - for (PositionedStack storedStack : comp) { - if (storedStack == null) continue; - ItemStack firstStack = storedStack.items[0].copy(); - boolean areItemStackEqual = firstStack.isItemEqual(currentStack) && ItemStack.areItemStackTagsEqual(firstStack, currentStack); - if (areItemStackEqual && (firstStack.stackSize + currentStack.stackSize) <= firstStack.getMaxStackSize()) { - find = true; - storedStack.items[0].stackSize = firstStack.stackSize + currentStack.stackSize; - } - } - if (!find) { - comp.add(positionedStack.copy()); - } - } - return comp.stream().filter(Objects::nonNull).collect(Collectors.toList()); - } - } diff --git a/src/main/java/com/glodblock/github/nei/recipes/extractor/GregTech6RecipeExtractor.java b/src/main/java/com/glodblock/github/nei/recipes/extractor/GregTech6RecipeExtractor.java index 90afa165..72adbc9f 100644 --- a/src/main/java/com/glodblock/github/nei/recipes/extractor/GregTech6RecipeExtractor.java +++ b/src/main/java/com/glodblock/github/nei/recipes/extractor/GregTech6RecipeExtractor.java @@ -3,6 +3,7 @@ package com.glodblock.github.nei.recipes.extractor; import codechicken.nei.PositionedStack; import com.glodblock.github.nei.object.IRecipeExtractor; import com.glodblock.github.nei.object.OrderStack; +import com.glodblock.github.util.NEIUtil; import gregapi.item.ItemFluidDisplay; import gregapi.recipes.Recipe; import net.minecraft.item.ItemStack; @@ -10,8 +11,6 @@ import net.minecraftforge.fluids.FluidStack; import java.util.LinkedList; import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; public class GregTech6RecipeExtractor implements IRecipeExtractor { @@ -24,7 +23,7 @@ public class GregTech6RecipeExtractor implements IRecipeExtractor { @Override public List> getInputIngredients(List rawInputs) { this.removeMachine(rawInputs); - List compressed = compress(rawInputs); + List compressed = NEIUtil.compress(rawInputs); List> tmp = new LinkedList<>(); for (int i = 0; i < compressed.size(); i ++) { if (compressed.get(i) == null) continue; @@ -45,7 +44,7 @@ public class GregTech6RecipeExtractor implements IRecipeExtractor { @Override public List> getOutputIngredients(List rawOutputs) { - List compressed = compress(rawOutputs); + List compressed = NEIUtil.compress(rawOutputs); List> tmp = new LinkedList<>(); for (int i = 0; i < compressed.size(); i ++) { if (compressed.get(i) == null) continue; @@ -78,27 +77,4 @@ public class GregTech6RecipeExtractor implements IRecipeExtractor { } } - private List compress(List list) { - List comp = new LinkedList<>(); - for (PositionedStack positionedStack : list) { - if (positionedStack == null) continue; - ItemStack currentStack = positionedStack.items[0].copy(); - if (currentStack.stackSize == 0) continue; - boolean find = false; - for (PositionedStack storedStack : comp) { - if (storedStack == null) continue; - ItemStack firstStack = storedStack.items[0].copy(); - boolean areItemStackEqual = firstStack.isItemEqual(currentStack) && ItemStack.areItemStackTagsEqual(firstStack, currentStack); - if (areItemStackEqual && (firstStack.stackSize + currentStack.stackSize) <= firstStack.getMaxStackSize()) { - find = true; - storedStack.items[0].stackSize = firstStack.stackSize + currentStack.stackSize; - } - } - if (!find) { - comp.add(positionedStack.copy()); - } - } - return comp.stream().filter(Objects::nonNull).collect(Collectors.toList()); - } - } diff --git a/src/main/java/com/glodblock/github/util/ModAndClassUtil.java b/src/main/java/com/glodblock/github/util/ModAndClassUtil.java index c2c0e306..e985aab6 100644 --- a/src/main/java/com/glodblock/github/util/ModAndClassUtil.java +++ b/src/main/java/com/glodblock/github/util/ModAndClassUtil.java @@ -17,6 +17,7 @@ public final class ModAndClassUtil { public static boolean EC2 = false; public static boolean EIO = false; public static boolean FTR = false; + public static boolean GTPP = false; public static boolean isDoubleButton; public static boolean isSaveText; @@ -95,7 +96,8 @@ public final class ModAndClassUtil { EIO = true; if (Loader.isModLoaded("Forestry")) FTR = true; - + if (Loader.isModLoaded("miscutils")) + GTPP = true; } diff --git a/src/main/java/com/glodblock/github/util/NEIUtil.java b/src/main/java/com/glodblock/github/util/NEIUtil.java new file mode 100644 index 00000000..6312c24b --- /dev/null +++ b/src/main/java/com/glodblock/github/util/NEIUtil.java @@ -0,0 +1,36 @@ +package com.glodblock.github.util; + +import codechicken.nei.PositionedStack; +import net.minecraft.item.ItemStack; + +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +public class NEIUtil { + + public static List compress(List list) { + List comp = new LinkedList<>(); + for (PositionedStack positionedStack : list) { + if (positionedStack == null) continue; + ItemStack currentStack = positionedStack.items[0].copy(); + if (currentStack.stackSize == 0) continue; + boolean find = false; + for (PositionedStack storedStack : comp) { + if (storedStack == null) continue; + ItemStack firstStack = storedStack.items[0].copy(); + boolean areItemStackEqual = firstStack.isItemEqual(currentStack) && ItemStack.areItemStackTagsEqual(firstStack, currentStack); + if (areItemStackEqual && (firstStack.stackSize + currentStack.stackSize) <= firstStack.getMaxStackSize()) { + find = true; + storedStack.items[0].stackSize = firstStack.stackSize + currentStack.stackSize; + } + } + if (!find) { + comp.add(positionedStack.copy()); + } + } + return comp.stream().filter(Objects::nonNull).collect(Collectors.toList()); + } + +}