aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/loaders
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/loaders')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingAngleGrinder.java (renamed from src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingAngelGrinder.java)4
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java2
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_FluidCanning.java235
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java25
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java12
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java10
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_AlgaeFarm.java202
7 files changed, 426 insertions, 64 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingAngelGrinder.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingAngleGrinder.java
index 1d20b56551..bf4e9b1390 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingAngelGrinder.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingAngleGrinder.java
@@ -19,8 +19,8 @@ import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_OreRecipeRegis
import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools;
import net.minecraft.item.ItemStack;
-public class ProcessingAngelGrinder implements Interface_OreRecipeRegistrator, Runnable {
- public ProcessingAngelGrinder() {
+public class ProcessingAngleGrinder implements Interface_OreRecipeRegistrator, Runnable {
+ public ProcessingAngleGrinder() {
GregtechOrePrefixes.toolAngleGrinder.add(this);
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java
index d8a5617b2e..d4a25e03dd 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java
@@ -266,7 +266,7 @@ public class RecipeGen_DustGeneration extends RecipeGen_Base {
//Get us four ItemStacks to input into the mixer
ItemStack input1, input2, input3, input4;
- input1 = (inputStacks.length >= 1) ? (input1 = (inputStacks[0] == null) ? null : inputStacks[0]) : null;
+ input1 = inputStacks[0];
input2 = (inputStacks.length >= 2) ? (input2 = (inputStacks[1] == null) ? null : inputStacks[1]) : null;
input3 = (inputStacks.length >= 3) ? (input3 = (inputStacks[2] == null) ? null : inputStacks[2]) : null;
input4 = (inputStacks.length >= 4) ? (input4 = (inputStacks[3] == null) ? null : inputStacks[3]) : null;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_FluidCanning.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_FluidCanning.java
index 7bc0eacd4f..40994040bd 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_FluidCanning.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_FluidCanning.java
@@ -1,61 +1,230 @@
package gtPlusPlus.xmod.gregtech.loaders;
import java.util.HashSet;
-import java.util.Set;
import gregtech.api.enums.GT_Values;
import gregtech.api.util.GT_Recipe;
-
+import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
+import gregtech.api.util.Recipe_GT;
import gtPlusPlus.api.interfaces.RunnableWithInfo;
-import gtPlusPlus.core.material.Material;
-import gtPlusPlus.core.material.MaterialGenerator;
-
-public class RecipeGen_FluidCanning extends RecipeGen_Base {
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.util.minecraft.ItemUtils;
+import gtPlusPlus.core.util.reflect.ReflectionUtils;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.FluidStack;
- public final static Set<RunnableWithInfo<Material>> mRecipeGenMap = new HashSet<RunnableWithInfo<Material>>();
- static {
- MaterialGenerator.mRecipeMapsToGenerate.put(mRecipeGenMap);
+public class RecipeGen_FluidCanning implements Runnable {
+
+ public static void init() {
+ FluidCanningRunnableHandler x = new FluidCanningRunnableHandler();
+ x.run();
}
+ private static class FluidCanningRunnableHandler implements RunnableWithInfo<String> {
+
+ @Override
+ public void run() {
+ mHasRun = true;
+ for (RecipeGen_FluidCanning aRecipe : mCache) {
+ aRecipe.run();
+ }
+ }
+
+ @Override
+ public String getInfoData() {
+ return "Fluid Canning Recipes";
+ }
+ }
+
+ private static boolean mHasRun = false;
+
+ private static HashSet<RecipeGen_FluidCanning> mCache = new HashSet<RecipeGen_FluidCanning>();
+
+ private static void addRunnableToRecipeCache(RecipeGen_FluidCanning r) {
+ if (mHasRun) {
+ CORE.crash();
+ }
+ mCache.add(r);
+ }
+
+ protected boolean disableOptional;
+
private final GT_Recipe recipe;
- public RecipeGen_FluidCanning(GT_Recipe g) {
- this(g, true);
+ private final boolean isValid;
+
+ public boolean valid() {
+ return isValid;
+ }
+ public RecipeGen_FluidCanning(boolean aExtracting, ItemStack aEmpty, ItemStack aFull, FluidStack aFluid) {
+ this(aExtracting, aEmpty, aFull, aFluid, GT_Values.NF, null, null);
+ }
+
+ public RecipeGen_FluidCanning(boolean aExtracting, ItemStack aEmpty, ItemStack aFull, FluidStack aFluidIn, FluidStack aFluidOut) {
+ this(aExtracting, aEmpty, aFull, aFluidIn, aFluidOut, null, null);
}
- public RecipeGen_FluidCanning(GT_Recipe g, boolean extracting) {
- recipe = g;
- mRecipeGenMap.add(this);
- disableOptional = extracting;
+
+ public RecipeGen_FluidCanning(boolean aExtracting, ItemStack aEmpty, ItemStack aFull, FluidStack aFluid, Integer aDuration, Integer aEUt) {
+ this(aExtracting, aEmpty, aFull, aFluid, GT_Values.NF, aDuration, aEUt);
+ }
+
+ // Alternative Constructor
+ public RecipeGen_FluidCanning(boolean aExtracting, ItemStack aEmpty, ItemStack aFull, FluidStack aFluidIn, FluidStack aFluidOut, Integer aDuration, Integer aEUt) {
+ ItemStack aInput;
+ ItemStack aOutput;
+ FluidStack aFluidInput;
+ FluidStack aFluidOutput;
+
+ // Safety check on the duration
+ if (aDuration == null || aDuration <= 0) {
+ aDuration = (aFluidIn != null) ? (aFluidIn.amount / 62) : ((aFluidOut != null) ? (aFluidOut.amount / 62) : 10);
+ }
+
+ // Safety check on the EU
+ if (aEUt == null || aEUt <= 0) {
+ if (aExtracting) {
+ aEUt = 2;
+ }
+ else {
+ aEUt = 1;
+ }
+ }
+
+ // Set Item stacks correctly, invert if extraction recipe.
+ if (aExtracting) {
+ aInput = aFull;
+ aOutput = aEmpty;
+ aFluidInput = GT_Values.NF;
+ aFluidOutput = aFluidIn;
+ }
+ else {
+ aInput = aEmpty;
+ aOutput = aFull;
+ aFluidInput = aFluidIn;
+ aFluidOutput = aFluidOut != null ? aFluidOut : GT_Values.NF;
+ }
+
+ //Check validity
+
+ Recipe_GT aRecipe = new Recipe_GT(
+ true,
+ new ItemStack[] { aInput },
+ new ItemStack[] { aOutput },
+ null,
+ new int[] {10000},
+ new FluidStack[] { aFluidInput },
+ new FluidStack[] { aFluidOutput },
+ aDuration,
+ aEUt,
+ 0);
+
+
+ // Check Valid
+ boolean aTempValidityCheck = false;
+ //Logger.INFO("Validity Check.");
+ if (aExtracting) {
+ Logger.INFO("Extracting.");
+ if (aInput != null && aFluidOutput != null) {
+ //Logger.INFO("Pass.");
+ aTempValidityCheck = true;
+ }
+ }
+ else {
+ //Logger.INFO("Canning.");
+ if (aInput != null && aOutput != null && (aFluidInput != null || aFluidOutput != null)) {
+ //Logger.INFO("Pass.");
+ aTempValidityCheck = true;
+ }
+ }
+
+
+ if (aTempValidityCheck) {
+ // Valid Recipe
+ recipe = aRecipe;
+ disableOptional = aExtracting;
+ isValid = true;
+ //Logger.INFO("Passed Validity Check. Hash: "+recipe.hashCode());
+ //Logger.INFO("Mapped as: "+(disableOptional ? "Extracting" : "Canning"));
+ addRunnableToRecipeCache(this);
+ }
+ else {
+ //Logger.INFO("Failed Validity Check.");
+ isValid = false;
+ disableOptional = aExtracting;
+ aRecipe.mEnabled = false;
+ aRecipe.mHidden = true;
+ recipe = null;
+ }
}
@Override
public void run() {
+ Logger.INFO("Processing Recipe with Hash: "+recipe.hashCode());
generateRecipes();
}
private void generateRecipes() {
- if (recipe != null) {
- //Used to store Fluid extraction state
+ if (isValid && recipe != null) {
+ //Logger.INFO("Processing "+(disableOptional ? "Extracting" : "Canning")+" Recipe.");
if (this.disableOptional) {
- GT_Values.RA.addFluidExtractionRecipe(
- recipe.mInputs.length >= 1 ? recipe.mInputs[0] : null, //Input
- recipe.mInputs.length == 2 ? recipe.mInputs[1] : null, //Input 2
- recipe.mFluidOutputs.length == 1 ? recipe.mFluidOutputs[0] : null, //Fluid Output
- recipe.mSpecialValue, //Chance
- recipe.mDuration, //Duration
- recipe.mEUt //Eu Tick
- );
+ addFluidExtractionRecipe(recipe);
}
else {
- GT_Values.RA.addFluidCannerRecipe(
- recipe.mInputs.length == 1 ? recipe.mInputs[0] : null, //Input
- recipe.mOutputs.length == 1 ? recipe.mOutputs[0] : null, //Input 2
- recipe.mFluidInputs.length == 1 ? recipe.mFluidInputs[0] : null, //Fluid Input
- recipe.mFluidOutputs.length == 1 ? recipe.mFluidOutputs[0] : null //Fluid Output
- );
-
+ addFluidCannerRecipe(recipe);
}
+ }
+ }
- }
+ private final boolean addFluidExtractionRecipe(GT_Recipe aRecipe) {
+ boolean result = false;
+ int aCount1 = GT_Recipe_Map.sFluidExtractionRecipes.mRecipeList.size();
+ int aCount2 = aCount1;
+ GT_Recipe_Map.sFluidExtractionRecipes.addRecipe(aRecipe);
+ aCount1 = GT_Recipe_Map.sFluidExtractionRecipes.mRecipeList.size();
+ result = aCount1 > aCount2;
+ if (result) {
+ //Logger.INFO("[FIND] Added Extraction recipe for "+ItemUtils.getArrayStackNames(aRecipe.mInputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mOutputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mFluidInputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mFluidOutputs));
+ }
+ else {
+ Logger.INFO("[ERROR] Failed adding Extraction recipe for "+ItemUtils.getArrayStackNames(aRecipe.mInputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mOutputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mFluidInputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mFluidOutputs));
+ //dumpStack();
+ }
+ return result;
+ }
+
+ private final boolean addFluidCannerRecipe(GT_Recipe aRecipe) {
+ boolean result = false;
+ int aCount1 = GT_Recipe_Map.sFluidCannerRecipes.mRecipeList.size();
+ int aCount2 = aCount1;
+ GT_Recipe_Map.sFluidCannerRecipes.addRecipe(aRecipe);
+ aCount1 = GT_Recipe_Map.sFluidCannerRecipes.mRecipeList.size();
+ result = aCount1 > aCount2;
+ if (result) {
+ //Logger.INFO("[FIND] Added Canning recipe for "+ItemUtils.getArrayStackNames(aRecipe.mInputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mOutputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mFluidInputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mFluidOutputs));
+ }
+ else {
+ Logger.INFO("[ERROR] Failed adding Canning recipe for "+ItemUtils.getArrayStackNames(aRecipe.mInputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mOutputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mFluidInputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mFluidOutputs));
+ //dumpStack();
+ }
+ return result;
+ }
+
+ private void dumpStack() {
+ int parents = 2;
+ for (int i=0;i<6;i++) {
+ Logger.INFO((disableOptional ? "EXTRACTING" : "CANNING")+" DEBUG | "+(i == 0 ? "Called from: " : "Parent: ")+ReflectionUtils.getMethodName(i+parents));
+ }
+
+ }
+
+ private String buildLogString() {
+ int solidSize = getMapSize(GT_Recipe_Map.sCannerRecipes);
+ int fluidSize = getMapSize(GT_Recipe_Map.sFluidCannerRecipes);
+ return (disableOptional ? "EXTRACTING" : "CANNING")+" DEBUG | Solids: "+solidSize+" | Liquids: "+fluidSize+" | ";
+ }
+
+ private final int getMapSize(GT_Recipe_Map aMap) {
+ return aMap.mRecipeList.size();
}
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java
index b2236fdd6c..2b4e52abb9 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java
@@ -48,10 +48,9 @@ public class RecipeGen_Fluids extends RecipeGen_Base {
// Ingot
if (ItemUtils.checkForInvalidItems(material.getIngot(1)))
- if (GT_Values.RA.addFluidExtractionRecipe(material.getIngot(1), // Input
- null, // Input 2
+ if (CORE.RA.addFluidExtractionRecipe(
+ material.getIngot(1), // Input
material.getFluid(144), // Fluid Output
- 0, // Chance
1 * 20, // Duration
material.vVoltageMultiplier // Eu Tick
)) {
@@ -64,10 +63,9 @@ public class RecipeGen_Fluids extends RecipeGen_Base {
// Plate
if (ItemUtils.checkForInvalidItems(material.getPlate(1)))
- if (GT_Values.RA.addFluidExtractionRecipe(material.getPlate(1), // Input
- null, // Input 2
+ if (CORE.RA.addFluidExtractionRecipe(
+ material.getPlate(1), // Input
material.getFluid(144), // Fluid Output
- 0, // Chance
1 * 20, // Duration
material.vVoltageMultiplier // Eu Tick
)) {
@@ -80,10 +78,9 @@ public class RecipeGen_Fluids extends RecipeGen_Base {
// Double Plate
if (ItemUtils.checkForInvalidItems(material.getPlateDouble(1)))
- if (GT_Values.RA.addFluidExtractionRecipe(material.getPlateDouble(1), // Input
- null, // Input 2
+ if (CORE.RA.addFluidExtractionRecipe(
+ material.getPlateDouble(1), // Input
material.getFluid(288), // Fluid Output
- 0, // Chance
1 * 20, // Duration
material.vVoltageMultiplier // Eu Tick
)) {
@@ -96,10 +93,9 @@ public class RecipeGen_Fluids extends RecipeGen_Base {
// Nugget
if (ItemUtils.checkForInvalidItems(material.getNugget(1)))
- if (GT_Values.RA.addFluidExtractionRecipe(material.getNugget(1), // Input
- null, // Input 2
+ if (CORE.RA.addFluidExtractionRecipe(
+ material.getNugget(1), // Input
material.getFluid(16), // Fluid Output
- 0, // Chance
16, // Duration
material.vVoltageMultiplier // Eu Tick
)) {
@@ -112,10 +108,9 @@ public class RecipeGen_Fluids extends RecipeGen_Base {
// Block
if (ItemUtils.checkForInvalidItems(material.getBlock(1)))
- if (GT_Values.RA.addFluidExtractionRecipe(material.getBlock(1), // Input
- null, // Input 2
+ if (CORE.RA.addFluidExtractionRecipe(
+ material.getBlock(1), // Input
material.getFluid(144 * 9), // Fluid Output
- 0, // Chance
288, // Duration
material.vVoltageMultiplier // Eu Tick
)) {
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java
index 1cb999241a..9b7e1d708d 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java
@@ -55,9 +55,6 @@ public class RecipeGen_Ore extends RecipeGen_Base {
//if (material.getMaterialComposites().length > 1){
Logger.MATERIALS("[Recipe Generator Debug] ["+material.getLocalizedName()+"]");
int tVoltageMultiplier = MaterialUtils.getVoltageForTier(material.vTier);
- if (tVoltageMultiplier < 120) {
- tVoltageMultiplier = material.getMeltingPointK() >= 2800 ? 480 : 120;
- }
final ItemStack dustStone = ItemUtils.getItemStackOfAmountFromOreDict("dustStone", 1);
Material bonusA = null; //Ni
@@ -222,9 +219,10 @@ public class RecipeGen_Ore extends RecipeGen_Base {
Logger.MATERIALS("material.getCrushed(1): "+(material.getCrushed(1) != null));
Logger.MATERIALS("material.getCrushedPurified(1): "+(material.getCrushedPurified(1) != null));
- Logger.MATERIALS("bonusA.getTinyDust(1): "+(tinyDustA != null)+" | Material: "+(bonusA != null) + " | Material name: "+(bonusA != null ? bonusA.getLocalizedName() : "invalid material"));
- Logger.MATERIALS("bonusB.getTinyDust(1): "+(tinyDustB != null)+" | Material: "+(bonusB != null) + " | Material name: "+(bonusB != null ? bonusB.getLocalizedName() : "invalid material"));
+ Logger.MATERIALS("material.getTinyDust(1): "+(ItemUtils.getItemName(bonusA.getCrushed(1))));
+ Logger.MATERIALS("material.getTinyDust(1): "+(ItemUtils.getItemName(bonusB.getCrushed(1))));
+
try {
//.08 compat
if (GT_ModHandler.addThermalCentrifugeRecipe(material.getCrushed(1), 200, material.getCrushedCentrifuged(1), tinyDustB, dustStone)){
@@ -362,7 +360,7 @@ public class RecipeGen_Ore extends RecipeGen_Base {
mInternalOutputs[4],
mInternalOutputs[5],
mChances,
- 20*1*(tVoltageMultiplier/10),
+ (int) Math.max(material.getMass() * 3L * 1, 1),
tVoltageMultiplier)){
Logger.MATERIALS("[Electrolyzer] Generated Electrolyzer recipe for "+matDust.getDisplayName());
}
@@ -445,7 +443,7 @@ public class RecipeGen_Ore extends RecipeGen_Base {
null,
mInternalOutputs,
mChances,
- 20*1*(tVoltageMultiplier/10),
+ (int) Math.max(material.getMass() * 4L * 1, 1),
tVoltageMultiplier)){
Logger.MATERIALS("[Dehydrator] Generated Dehydrator recipe for "+matDust.getDisplayName());
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java
index f0c2785e1b..84188a44aa 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java
@@ -7,16 +7,11 @@ import java.util.Map;
import org.apache.commons.lang3.reflect.FieldUtils;
-import net.minecraft.init.Items;
-import net.minecraft.item.ItemStack;
-
-import gregtech.api.enums.GT_Values;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Utility;
-
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.api.objects.data.AutoMap;
import gtPlusPlus.api.objects.data.Pair;
@@ -26,6 +21,8 @@ import gtPlusPlus.core.material.state.MaterialState;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.minecraft.ItemUtils;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
public class RecipeGen_Recycling implements Runnable {
@@ -60,6 +57,7 @@ public class RecipeGen_Recycling implements Runnable {
public static void generateRecipes(final Material material) {
+ if (material != null)
Logger.WARNING("Generating Recycling recipes for " + material.getLocalizedName());
final OrePrefixes[] mValidPrefixesAsString = { OrePrefixes.ingot, OrePrefixes.ingotHot, OrePrefixes.nugget,
@@ -139,7 +137,7 @@ public class RecipeGen_Recycling implements Runnable {
//Fluid Extractor
if (ItemUtils.checkForInvalidItems(tempStack)) {
// mValidItems[mSlotIndex++] = tempStack;
- if ((mDust != null) && GT_Values.RA.addFluidExtractionRecipe(tempStack, null, material.getFluid(mFluidAmount), 0, 30, material.vVoltageMultiplier)) {
+ if ((mDust != null) && CORE.RA.addFluidExtractionRecipe(tempStack, material.getFluid(mFluidAmount), 30, material.vVoltageMultiplier)) {
Logger.WARNING("Fluid Recycle Recipe: " + material.getLocalizedName() + " - Success - Recycle "
+ tempStack.getDisplayName() + " and obtain " + mFluidAmount+"mb of "+material.getFluid(1).getLocalizedName()+".");
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_AlgaeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_AlgaeFarm.java
new file mode 100644
index 0000000000..8a4ae1344a
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_AlgaeFarm.java
@@ -0,0 +1,202 @@
+package gtPlusPlus.xmod.gregtech.loaders.recipe;
+
+import java.util.HashMap;
+
+import gregtech.api.enums.GT_Values;
+import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.Recipe_GT;
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.api.objects.data.WeightedCollection;
+import gtPlusPlus.core.item.chemistry.AgriculturalChem;
+import gtPlusPlus.core.util.math.MathUtils;
+import gtPlusPlus.core.util.minecraft.ItemUtils;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.FluidStack;
+
+public class RecipeLoader_AlgaeFarm {
+
+ private static final HashMap<Integer, AutoMap<GT_Recipe>> mRecipeCache = new HashMap<Integer, AutoMap<GT_Recipe>>();
+ private static final HashMap<Integer, AutoMap<GT_Recipe>> mRecipeCompostCache = new HashMap<Integer, AutoMap<GT_Recipe>>();
+
+ public static final void generateRecipes() {
+ for (int i=0;i<10;i++) {
+ getTieredRecipeFromCache(i, false);
+ }
+ for (int i=0;i<10;i++) {
+ getTieredRecipeFromCache(i, true);
+ }
+ }
+
+ public static GT_Recipe getTieredRecipeFromCache(int aTier, boolean aCompost) {
+ HashMap<Integer, AutoMap<GT_Recipe>> aMap = aCompost ? mRecipeCompostCache : mRecipeCache;
+ String aComp = aCompost ? "(Compost)" : "";
+
+ AutoMap<GT_Recipe> aTemp = aMap.get(aTier);
+ if (aTemp == null || aTemp.isEmpty()) {
+ aTemp = new AutoMap<GT_Recipe>();
+ aMap.put(aTier, aTemp);
+ Logger.INFO("Tier "+aTier+aComp+" had no recipes, initialising new map.");
+ }
+ if (aTemp.size() < 500) {
+ Logger.INFO("Tier "+aTier+aComp+" has less than 500 recipes, generating "+(500 - aTemp.size())+".");
+ for (int i=aTemp.size();i<500;i++) {
+ aTemp.put(generateBaseRecipe(aCompost, aTier));
+ }
+ }
+ int aIndex = MathUtils.randInt(0, aTemp.isEmpty() ? 1 : aTemp.size());
+ Logger.INFO("Using recipe with index of "+aIndex+". "+aComp);
+ return aTemp.get(aIndex);
+ }
+
+ private static GT_Recipe generateBaseRecipe(boolean aUsingCompost, int aTier) {
+
+ // Type Safety
+ if (aTier < 0) {
+ return null;
+ }
+
+ WeightedCollection<Float> aOutputTimeMulti = new WeightedCollection<Float>();
+ for (int i=100;i> 0;i--) {
+ float aValue = 0;
+ if (i < 10) {
+ aValue = 3f;
+ }
+ else if (i < 20) {
+ aValue = 2f;
+ }
+ else {
+ aValue = 1f;
+ }
+ aOutputTimeMulti.put(i, aValue);
+ }
+
+ final int[] aDurations = new int[] {
+ 432000,
+ 378000,
+ 216000,
+ 162000,
+ 108000,
+ 81000,
+ 54000,
+ 40500,
+ 27000,
+ 20250,
+ 13500,
+ 6750,
+ 3375,
+ 1686,
+ 843,
+ 421
+ };
+
+ ItemStack[] aInputs = new ItemStack[] {};
+
+ if (aUsingCompost) {
+ // Make it use 4 compost per tier if we have some available
+ ItemStack aCompost = ItemUtils.getSimpleStack(AgriculturalChem.mCompost, aTier * 4);
+ aInputs = new ItemStack[] {aCompost};
+ // Boost Tier by one if using compost so it gets a speed boost
+ aTier++;
+ }
+
+ // We set these elsewhere
+ ItemStack[] aOutputs = getOutputsForTier(aTier);
+
+ GT_Recipe tRecipe = new Recipe_GT(
+ false,
+ aInputs,
+ aOutputs,
+ (Object) null,
+ new int[] {},
+ new FluidStack[] {GT_Values.NF},
+ new FluidStack[] {GT_Values.NF},
+ (int) (aDurations[aTier] * aOutputTimeMulti.get()), // Time
+ 0,
+ 0);
+
+ tRecipe.mSpecialValue = tRecipe.hashCode();
+
+ return tRecipe;
+ }
+
+ private static ItemStack[] getOutputsForTier(int aTier) {
+
+ // Create an Automap to dump contents into
+ AutoMap<ItemStack> aOutputMap = new AutoMap<ItemStack>();
+
+ // Add loot relevant to tier and also add any from lower tiers.
+ if (aTier >= 0) {
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mAlgaeBiosmass, MathUtils.randInt(16, 32)));
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mAlgaeBiosmass, MathUtils.randInt(32, 64)));
+ if (MathUtils.randInt(0, 10) > 9) {
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, MathUtils.randInt(8, 16)));
+ }
+ }
+ if (aTier >= 1) {
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mAlgaeBiosmass, MathUtils.randInt(16, 32)));
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, MathUtils.randInt(16, 32)));
+ if (MathUtils.randInt(0, 10) > 9) {
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, MathUtils.randInt(4, 8)));
+ }
+ }
+ if (aTier >= 2) {
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, MathUtils.randInt(8, 16)));
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, MathUtils.randInt(16, 32)));
+ if (MathUtils.randInt(0, 10) > 9) {
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, MathUtils.randInt(4, 8)));
+ }
+ }
+ if (aTier >= 3) {
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, MathUtils.randInt(16, 32)));
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, MathUtils.randInt(2, 8)));
+ if (MathUtils.randInt(0, 10) > 9) {
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, MathUtils.randInt(8, 16)));
+ }
+ }
+ if (aTier >= 4) {
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, MathUtils.randInt(16, 32)));
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, MathUtils.randInt(32, 64)));
+ if (MathUtils.randInt(0, 10) > 9) {
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGoldenBrownAlgaeBiosmass, MathUtils.randInt(4, 8)));
+ }
+ }
+ if (aTier >= 5) {
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, MathUtils.randInt(16, 32)));
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGoldenBrownAlgaeBiosmass, MathUtils.randInt(16, 32)));
+ if (MathUtils.randInt(0, 10) > 9) {
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mRedAlgaeBiosmass, MathUtils.randInt(1, 2)));
+ }
+ }
+ // Tier 6 is Highest for outputs
+ if (aTier >= 6) {
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGoldenBrownAlgaeBiosmass, MathUtils.randInt(16, 32)));
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mRedAlgaeBiosmass, MathUtils.randInt(8, 16)));
+ if (MathUtils.randInt(0, 10) > 9) {
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mRedAlgaeBiosmass, MathUtils.randInt(8, 16)));
+ }
+ }
+
+ // Iterate a special loop at higher tiers to provide more Red/Gold Algae.
+ for (int i=0;i<(9-aTier);i++) {
+ if (aTier >= (6+i)) {
+ int aMulti = i + 1;
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGoldenBrownAlgaeBiosmass, MathUtils.randInt(4, 8*aMulti)));
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mRedAlgaeBiosmass, MathUtils.randInt(4, 8*aMulti)));
+ if (MathUtils.randInt(0, 10) > 8) {
+ aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mRedAlgaeBiosmass, MathUtils.randInt(8, 16*aMulti)));
+ }
+ }
+ }
+
+ // Map the AutoMap contents to an Itemstack Array.
+ ItemStack[] aOutputs = new ItemStack[aOutputMap.size()];
+ for (int i=0;i<aOutputMap.size();i++) {
+ aOutputs[i] = aOutputMap.get(i);
+ }
+
+ // Return filled ItemStack Array.
+ return aOutputs;
+ }
+
+}