aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe
diff options
context:
space:
mode:
authorAlexdoru <57050655+Alexdoru@users.noreply.github.com>2024-10-09 18:11:00 +0200
committerGitHub <noreply@github.com>2024-10-09 18:11:00 +0200
commitd2a9ed7be356fda78de11a5bceedec501a9f1ffc (patch)
tree68e0141f05d6f52b53c2906c2a6deeacfac05d36 /src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe
parentb27b4c35fb01bdabe29abf780486475e2d758e9c (diff)
downloadGT5-Unofficial-d2a9ed7be356fda78de11a5bceedec501a9f1ffc.tar.gz
GT5-Unofficial-d2a9ed7be356fda78de11a5bceedec501a9f1ffc.tar.bz2
GT5-Unofficial-d2a9ed7be356fda78de11a5bceedec501a9f1ffc.zip
Remove tremendous and useless RAM allocation from GT++ algae pond recipes (#3338)
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe')
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoaderAlgaeFarm.java190
1 files changed, 0 insertions, 190 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoaderAlgaeFarm.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoaderAlgaeFarm.java
deleted file mode 100644
index 0ec27e6cee..0000000000
--- a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoaderAlgaeFarm.java
+++ /dev/null
@@ -1,190 +0,0 @@
-package gtPlusPlus.xmod.gregtech.loaders.recipe;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import net.minecraft.item.ItemStack;
-import net.minecraftforge.fluids.FluidStack;
-
-import gregtech.api.enums.GTValues;
-import gregtech.api.util.GTRecipe;
-import gtPlusPlus.api.objects.Logger;
-import gtPlusPlus.api.objects.data.WeightedCollection;
-import gtPlusPlus.core.item.chemistry.AgriculturalChem;
-import gtPlusPlus.core.util.math.MathUtils;
-import gtPlusPlus.core.util.minecraft.ItemUtils;
-
-public class RecipeLoaderAlgaeFarm {
-
- private static final HashMap<Integer, ArrayList<GTRecipe>> mRecipeCache = new HashMap<>();
- private static final HashMap<Integer, ArrayList<GTRecipe>> mRecipeCompostCache = new HashMap<>();
-
- public static void generateRecipes() {
- for (int i = 0; i < 15; i++) {
- getTieredRecipeFromCache(i, false);
- }
- for (int i = 0; i < 15; i++) {
- getTieredRecipeFromCache(i, true);
- }
- }
-
- public static GTRecipe getTieredRecipeFromCache(int aTier, boolean aCompost) {
- HashMap<Integer, ArrayList<GTRecipe>> aMap = aCompost ? mRecipeCompostCache : mRecipeCache;
- String aComp = aCompost ? "(Compost)" : "";
-
- ArrayList<GTRecipe> aTemp = aMap.get(aTier);
- if (aTemp == null || aTemp.isEmpty()) {
- aTemp = new ArrayList<>();
- 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.add(generateBaseRecipe(aCompost, aTier));
- }
- }
- int aIndex = MathUtils.randInt(0, (aTemp.isEmpty() ? 1 : aTemp.size()) - 1);
- Logger.INFO("Using recipe with index of " + aIndex + ". " + aComp);
- return aTemp.get(aIndex);
- }
-
- public static int compostForTier(int aTier) {
- return aTier > 1 ? (int) Math.min(64, Math.pow(2, aTier - 1)) : 1;
- }
-
- private static GTRecipe generateBaseRecipe(boolean aUsingCompost, int aTier) {
-
- // Type Safety
- if (aTier < 0) {
- return null;
- }
-
- WeightedCollection<Float> aOutputTimeMulti = new WeightedCollection<>();
- 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[] { 2000, 1800, 1600, 1400, 1200, 1000, 512, 256, 128, 64, 32, 16, 8, 4, 2,
- 1 };
-
- ItemStack[] aInputs = new ItemStack[] {};
-
- if (aUsingCompost) {
- // Make it use 4 compost per tier if we have some available
- // Compost consumption maxes out at 1 stack per cycle
- ItemStack aCompost = ItemUtils.getSimpleStack(AgriculturalChem.mCompost, compostForTier(aTier));
- 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);
-
- GTRecipe tRecipe = new GTRecipe(
- false,
- aInputs,
- aOutputs,
- null,
- new int[] {},
- new FluidStack[] { GTValues.NF },
- new FluidStack[] { GTValues.NF },
- (int) (aDurations[aTier] * aOutputTimeMulti.get() / 2), // Time
- 0,
- 0);
-
- tRecipe.mSpecialValue = tRecipe.hashCode();
-
- return tRecipe;
- }
-
- private static ItemStack[] getOutputsForTier(int aTier) {
- ArrayList<ItemStack> aOutputMap = new ArrayList<>();
-
- // Add loot relevant to tier and also add any from lower tiers.
-
- if (aTier >= 0) {
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mAlgaeBiosmass, 2));
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mAlgaeBiosmass, 4));
- if (MathUtils.randInt(0, 10) > 9) {
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, 2));
- }
- }
-
- if (aTier >= 1) {
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mAlgaeBiosmass, 4));
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, 2));
- if (MathUtils.randInt(0, 10) > 9) {
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, 4));
- }
- }
- if (aTier >= 2) {
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, 2));
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, 3));
- if (MathUtils.randInt(0, 10) > 9) {
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, 8));
- }
- }
- if (aTier >= 3) {
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, 4));
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, 1));
- if (MathUtils.randInt(0, 10) > 9) {
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, 4));
- }
- }
- if (aTier >= 4) {
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, 2));
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, 3));
- if (MathUtils.randInt(0, 10) > 9) {
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mGoldenBrownAlgaeBiosmass, 4));
- }
- }
- if (aTier >= 5) {
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, 4));
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mGoldenBrownAlgaeBiosmass, 2));
- if (MathUtils.randInt(0, 10) > 9) {
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mRedAlgaeBiosmass, 4));
- }
- }
- // Tier 6 is Highest for outputs
- if (aTier >= 6) {
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mGoldenBrownAlgaeBiosmass, 4));
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mRedAlgaeBiosmass, 2));
- if (MathUtils.randInt(0, 10) > 9) {
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mRedAlgaeBiosmass, 8));
- }
- }
-
- // Iterate a special loop at higher tiers to provide more Red/Gold Algae.
- for (int i2 = 0; i2 < 20; i2++) {
- if (aTier >= (6 + i2)) {
- int aMulti = i2 + 1;
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, aMulti * 4));
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, aMulti * 3));
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mGoldenBrownAlgaeBiosmass, aMulti * 2));
- aOutputMap.add(ItemUtils.getSimpleStack(AgriculturalChem.mRedAlgaeBiosmass, aMulti));
- } else {
- i2 = 20;
- }
- }
-
- // 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;
- }
-}