aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util/GT_ModHandler.java
diff options
context:
space:
mode:
authorJohn <Techlone@users.noreply.github.com>2017-01-14 04:05:25 +0500
committerGitHub <noreply@github.com>2017-01-14 04:05:25 +0500
commitc39c6f8beae48e2ed63d70f8223b899b49fef537 (patch)
tree7b57bcedd0ef8a506d0f35417a20018fc9ebdf13 /src/main/java/gregtech/api/util/GT_ModHandler.java
parent75fc96694a7ce15618e6da1d52cd05f77b77169e (diff)
parent5c5aad452228255815deab8ff3bcb85e147ef63b (diff)
downloadGT5-Unofficial-c39c6f8beae48e2ed63d70f8223b899b49fef537.tar.gz
GT5-Unofficial-c39c6f8beae48e2ed63d70f8223b899b49fef537.tar.bz2
GT5-Unofficial-c39c6f8beae48e2ed63d70f8223b899b49fef537.zip
Merge pull request #4 from Blood-Asp/unstable
update
Diffstat (limited to 'src/main/java/gregtech/api/util/GT_ModHandler.java')
-rw-r--r--src/main/java/gregtech/api/util/GT_ModHandler.java76
1 files changed, 60 insertions, 16 deletions
diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java
index 422427a304..6737268d64 100644
--- a/src/main/java/gregtech/api/util/GT_ModHandler.java
+++ b/src/main/java/gregtech/api/util/GT_ModHandler.java
@@ -1,6 +1,5 @@
package gregtech.api.util;
-import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.GT_Mod;
@@ -39,7 +38,6 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
-import java.lang.reflect.Method;
import java.util.*;
import java.util.Map.Entry;
@@ -501,9 +499,10 @@ public class GT_ModHandler {
public static boolean addExtractionRecipe(ItemStack aInput, ItemStack aOutput) {
aOutput = GT_OreDictUnificator.get(true, aOutput);
if (aInput == null || aOutput == null) return false;
- GT_Utility.removeSimpleIC2MachineRecipe(aInput, getExtractorRecipeList(), null);
+ if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.removeSimpleIC2MachineRecipe(aInput, getExtractorRecipeList(), null);
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.extractor, aInput, true)) return false;
- GT_Utility.addSimpleIC2MachineRecipe(aInput, getExtractorRecipeList(), null, aOutput);
+ RA.addExtractorRecipe(aInput, aOutput, 100, 32);
+ if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.addSimpleIC2MachineRecipe(aInput, getExtractorRecipeList(), null, aOutput);
return true;
}
@@ -555,10 +554,10 @@ public class GT_ModHandler {
aOutput1 = GT_OreDictUnificator.get(true, aOutput1);
aOutput2 = GT_OreDictUnificator.get(true, aOutput2);
if (GT_Utility.isStackInvalid(aInput) || GT_Utility.isStackInvalid(aOutput1)) return false;
- GT_Utility.removeSimpleIC2MachineRecipe(aInput, getMaceratorRecipeList(), null);
+ if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.removeSimpleIC2MachineRecipe(aInput, getMaceratorRecipeList(), null);
if (GT_Utility.getContainerItem(aInput, false) == null) {
- if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.maceration, aInput, true)) {
+ if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines && GregTech_API.sRecipeFile.get(ConfigCategories.Machines.maceration, aInput, true)) {
GT_Utility.addSimpleIC2MachineRecipe(aInput, getMaceratorRecipeList(), null, aOutput1);
}
addMagneticraftRecipe(aInput, aOutput1, aOutput2, aChance2, aOutput3, aChance3);
@@ -672,6 +671,44 @@ public class GT_ModHandler {
return true;
}
+ /**
+ * Adds GT versions of the IC2 recipes from the supplied IC2RecipeList.
+ */
+ public static void addIC2RecipesToGT(Map<IRecipeInput, RecipeOutput> aIC2RecipeList, GT_Recipe.GT_Recipe_Map aGTRecipeMap, boolean aAddGTRecipe, boolean aRemoveIC2Recipe, boolean aExcludeGTIC2Items) {
+ Map<ItemStack, ItemStack> aRecipesToRemove = new HashMap<>();
+ for (Iterator i$ = aIC2RecipeList.entrySet().iterator(); i$.hasNext(); ) {
+ Entry tRecipe = (Map.Entry) i$.next();
+ if (((RecipeOutput) tRecipe.getValue()).items.size() > 0) {
+ for (ItemStack tStack : ((IRecipeInput) tRecipe.getKey()).getInputs()) {
+ if (GT_Utility.isStackValid(tStack)) {
+ if (aAddGTRecipe && (aGTRecipeMap.findRecipe(null, false, Long.MAX_VALUE, null, tStack) == null)) {
+ if (aExcludeGTIC2Items && ((tStack.getUnlocalizedName().contains("gt.metaitem.01") || tStack.getUnlocalizedName().contains("gt.blockores") || tStack.getUnlocalizedName().contains("ic2.itemCrushed") || tStack.getUnlocalizedName().contains("ic2.itemPurifiedCrushed")))) continue;
+ switch (aGTRecipeMap.mUnlocalizedName) {
+ case "gt.recipe.macerator":
+ aGTRecipeMap.addRecipe(true, new ItemStack[]{GT_Utility.copyAmount(((IRecipeInput) tRecipe.getKey()).getAmount(), tStack)}, (ItemStack[]) ((RecipeOutput) tRecipe.getValue()).items.toArray(), null, null, null, null, 400, 2, 0);
+ break;
+ case "gt.recipe.compressor":
+ aGTRecipeMap.addRecipe(true, new ItemStack[]{GT_Utility.copyAmount(((IRecipeInput) tRecipe.getKey()).getAmount(), tStack)}, (ItemStack[]) ((RecipeOutput) tRecipe.getValue()).items.toArray(), null, null, null, null, 400, 2, 0);
+ break;
+ case "gt.recipe.extractor":
+ aGTRecipeMap.addRecipe(true, new ItemStack[]{GT_Utility.copyAmount(((IRecipeInput) tRecipe.getKey()).getAmount(), tStack)}, (ItemStack[]) ((RecipeOutput) tRecipe.getValue()).items.toArray(), null, null, null, null, 100, 32, 0);
+ break;
+ case "gt.recipe.thermalcentrifuge":
+ aGTRecipeMap.addRecipe(true, new ItemStack[]{GT_Utility.copyAmount(((IRecipeInput) tRecipe.getKey()).getAmount(), tStack)}, (ItemStack[]) ((RecipeOutput) tRecipe.getValue()).items.toArray(), null, null, null, null, 400, 48, 0);
+ break;
+ }
+ //System.out.println("#####Processed IC2 " + aGTRecipeMap.mUnlocalizedName + " Recipe: In(" + tStack.getUnlocalizedName() + ") - Out(" + ((RecipeOutput) tRecipe.getValue()).items.get(0).getUnlocalizedName() + ")");
+ }
+ if (aRemoveIC2Recipe) aRecipesToRemove.put(tStack, ((RecipeOutput) tRecipe.getValue()).items.get(0));
+ }
+ }
+ }
+ }
+ for (Entry<ItemStack, ItemStack> aEntry : aRecipesToRemove.entrySet()) {
+ GT_Utility.removeSimpleIC2MachineRecipe(aEntry.getKey(), aIC2RecipeList, aEntry.getValue());
+ }
+ }
+
public static Map<IRecipeInput, RecipeOutput> getExtractorRecipeList() {
try {
return ic2.api.recipe.Recipes.extractor.getRecipes();
@@ -719,11 +756,14 @@ public class GT_ModHandler {
*/
public static boolean addThermalCentrifugeRecipe(ItemStack aInput, int aHeat, Object... aOutput) {
if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false;
- GT_Utility.removeSimpleIC2MachineRecipe(aInput, getThermalCentrifugeRecipeList(), null);
+ if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.removeSimpleIC2MachineRecipe(aInput, getThermalCentrifugeRecipeList(), null);
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.thermalcentrifuge, aInput, true)) return false;
- NBTTagCompound tNBT = new NBTTagCompound();
- tNBT.setInteger("minHeat", aHeat);
- GT_Utility.addSimpleIC2MachineRecipe(aInput, getThermalCentrifugeRecipeList(), tNBT, aOutput);
+ RA.addThermalCentrifugeRecipe(aInput, aOutput.length >= 1 ? (ItemStack)aOutput[0] : null, aOutput.length >= 2 ? (ItemStack)aOutput[1] : null, aOutput.length >= 3 ? (ItemStack)aOutput[2] : null, 400, 48);
+ if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) {
+ NBTTagCompound tNBT = new NBTTagCompound();
+ tNBT.setInteger("minHeat", aHeat);
+ GT_Utility.addSimpleIC2MachineRecipe(aInput, getThermalCentrifugeRecipeList(), tNBT, aOutput);
+ }
return true;
}
@@ -732,11 +772,14 @@ public class GT_ModHandler {
*/
public static boolean addOreWasherRecipe(ItemStack aInput, int aWaterAmount, Object... aOutput) {
if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false;
- GT_Utility.removeSimpleIC2MachineRecipe(aInput, getOreWashingRecipeList(), null);
+ if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.removeSimpleIC2MachineRecipe(aInput, getOreWashingRecipeList(), null);
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.orewashing, aInput, true)) return false;
- NBTTagCompound tNBT = new NBTTagCompound();
- tNBT.setInteger("amount", aWaterAmount);
- GT_Utility.addSimpleIC2MachineRecipe(aInput, getOreWashingRecipeList(), tNBT, aOutput);
+ RA.addOreWasherRecipe(aInput, (ItemStack)aOutput[0], (ItemStack)aOutput[1], (ItemStack)aOutput[2], GT_ModHandler.getWater(1000L), 400, 16);
+ if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) {
+ NBTTagCompound tNBT = new NBTTagCompound();
+ tNBT.setInteger("amount", aWaterAmount);
+ GT_Utility.addSimpleIC2MachineRecipe(aInput, getOreWashingRecipeList(), tNBT, aOutput);
+ }
return true;
}
@@ -746,9 +789,10 @@ public class GT_ModHandler {
public static boolean addCompressionRecipe(ItemStack aInput, ItemStack aOutput) {
aOutput = GT_OreDictUnificator.get(true, aOutput);
if (aInput == null || aOutput == null || GT_Utility.areStacksEqual(aInput, aOutput, true)) return false;
- GT_Utility.removeSimpleIC2MachineRecipe(aInput, getCompressorRecipeList(), null);
+ if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.removeSimpleIC2MachineRecipe(aInput, getCompressorRecipeList(), null);
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.compression, aInput, true)) return false;
- GT_Utility.addSimpleIC2MachineRecipe(aInput, getCompressorRecipeList(), null, aOutput);
+ RA.addCompressorRecipe(aInput, aOutput, 400, 2);
+ if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.addSimpleIC2MachineRecipe(aInput, getCompressorRecipeList(), null, aOutput);
return true;
}