aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/tectech/recipe/EyeOfHarmonyRecipeStorage.java
diff options
context:
space:
mode:
authorNotAPenguin <michiel.vandeginste@gmail.com>2024-09-02 23:17:17 +0200
committerGitHub <noreply@github.com>2024-09-02 23:17:17 +0200
commit1b820de08a05070909a267e17f033fcf58ac8710 (patch)
tree02831a025986a06b20f87e5bcc69d1e0c639a342 /src/main/java/tectech/recipe/EyeOfHarmonyRecipeStorage.java
parentafd3fd92b6a6ab9ab0d0dc3214e6bc8ff7a86c9b (diff)
downloadGT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.tar.gz
GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.tar.bz2
GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.zip
The Great Renaming (#3014)
* move kekztech to a single root dir * move detrav to a single root dir * move gtnh-lanthanides to a single root dir * move tectech and delete some gross reflection in gt++ * remove more reflection inside gt5u * delete more reflection in gt++ * fix imports * move bartworks and bwcrossmod * fix proxies * move galactigreg and ggfab * move gtneioreplugin * try to fix gt++ bee loader * apply the rename rules to BW * apply rename rules to bwcrossmod * apply rename rules to detrav scanner mod * apply rename rules to galacticgreg * apply rename rules to ggfab * apply rename rules to goodgenerator * apply rename rules to gtnh-lanthanides * apply rename rules to gt++ * apply rename rules to kekztech * apply rename rules to kubatech * apply rename rules to tectech * apply rename rules to gt apply the rename rules to gt * fix tt import * fix mui hopefully * fix coremod except intergalactic * rename assline recipe class * fix a class name i stumbled on * rename StructureUtility to GTStructureUtility to prevent conflict with structurelib * temporary rename of GTTooltipDataCache to old name * fix gt client/server proxy names
Diffstat (limited to 'src/main/java/tectech/recipe/EyeOfHarmonyRecipeStorage.java')
-rw-r--r--src/main/java/tectech/recipe/EyeOfHarmonyRecipeStorage.java186
1 files changed, 186 insertions, 0 deletions
diff --git a/src/main/java/tectech/recipe/EyeOfHarmonyRecipeStorage.java b/src/main/java/tectech/recipe/EyeOfHarmonyRecipeStorage.java
new file mode 100644
index 0000000000..30671dc919
--- /dev/null
+++ b/src/main/java/tectech/recipe/EyeOfHarmonyRecipeStorage.java
@@ -0,0 +1,186 @@
+package tectech.recipe;
+
+import static java.lang.Math.pow;
+import static tectech.recipe.EyeOfHarmonyRecipe.processHelper;
+import static tectech.recipe.TecTechRecipeMaps.eyeOfHarmonyRecipes;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+
+import net.minecraft.block.Block;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.FluidStack;
+
+import org.apache.commons.lang3.tuple.Pair;
+
+import com.google.common.math.LongMath;
+
+import gregtech.api.enums.GTValues;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.MaterialsUEVplus;
+import gregtech.api.enums.OrePrefixes;
+import gregtech.api.util.GTOreDictUnificator;
+import gtneioreplugin.plugin.block.BlockDimensionDisplay;
+import gtneioreplugin.plugin.block.ModBlocks;
+import gtneioreplugin.util.DimensionHelper;
+import gtneioreplugin.util.GT5OreLayerHelper;
+import gtneioreplugin.util.GT5OreSmallHelper;
+import tectech.util.FluidStackLong;
+import tectech.util.ItemStackLong;
+
+public class EyeOfHarmonyRecipeStorage {
+
+ public static final long BILLION = LongMath.pow(10, 9);
+ private static final double CHANCE_DECREASE_PER_DIMENSION = 0.05;
+
+ // Map is unique so this is fine.
+ HashMap<Block, String> blocksMapInverted = new HashMap<>() {
+
+ private static final long serialVersionUID = -1634011860327553337L;
+
+ {
+ ModBlocks.blocks.forEach((dimString, dimBlock) -> { put(dimBlock, dimString); });
+ }
+ };
+
+ private final HashMap<String, EyeOfHarmonyRecipe> recipeHashMap = new HashMap<String, EyeOfHarmonyRecipe>() {
+
+ private static final long serialVersionUID = -3501819612517400500L;
+
+ {
+ for (String dimAbbreviation : DimensionHelper.DimNameDisplayed) {
+ BlockDimensionDisplay blockDimensionDisplay = (BlockDimensionDisplay) ModBlocks.blocks
+ .get(dimAbbreviation);
+
+ if (dimAbbreviation.equals("DD")) {
+ specialDeepDarkRecipe(this, blockDimensionDisplay);
+ } else {
+
+ GT5OreLayerHelper.NormalOreDimensionWrapper normalOre = GT5OreLayerHelper.dimToOreWrapper
+ .getOrDefault(dimAbbreviation, null);
+ GT5OreSmallHelper.SmallOreDimensionWrapper smallOre = GT5OreSmallHelper.dimToSmallOreWrapper
+ .getOrDefault(dimAbbreviation, null);
+ if (normalOre == null && smallOre == null) {
+ // No ores are generated in this dimension. Fail silently.
+ continue;
+ }
+
+ long spacetimeTier = blockDimensionDisplay.getDimensionRocketTier();
+ if (spacetimeTier == 0) {
+ spacetimeTier += 1;
+ }
+
+ put(
+ dimAbbreviation,
+ new EyeOfHarmonyRecipe(
+ normalOre,
+ smallOre,
+ blockDimensionDisplay,
+ 0.6 + blockDimensionDisplay.getDimensionRocketTier() / 10.0,
+ BILLION * (blockDimensionDisplay.getDimensionRocketTier() + 1),
+ BILLION * (blockDimensionDisplay.getDimensionRocketTier() + 1),
+ timeCalculator(blockDimensionDisplay.getDimensionRocketTier()),
+ spacetimeTier - 1,
+ 1.0 - CHANCE_DECREASE_PER_DIMENSION * blockDimensionDisplay.getDimensionRocketTier()));
+ }
+ }
+ }
+ };
+
+ public EyeOfHarmonyRecipe recipeLookUp(final ItemStack aStack) {
+ String dimAbbreviation = blocksMapInverted.get(Block.getBlockFromItem(aStack.getItem()));
+ return recipeHashMap.get(dimAbbreviation);
+ }
+
+ public EyeOfHarmonyRecipeStorage() {
+
+ for (EyeOfHarmonyRecipe recipe : recipeHashMap.values()) {
+
+ ArrayList<ItemStack> outputItems = new ArrayList<>();
+ for (ItemStackLong itemStackLong : recipe.getOutputItems()) {
+ outputItems.add(itemStackLong.itemStack);
+ }
+
+ ArrayList<FluidStack> outputFluids = new ArrayList<>();
+ for (FluidStackLong fluidStackLong : recipe.getOutputFluids()) {
+ outputFluids.add(fluidStackLong.fluidStack);
+ }
+
+ ItemStack planetItem = recipe.getRecipeTriggerItem()
+ .copy();
+ planetItem.stackSize = 0;
+
+ GTValues.RA.stdBuilder()
+ .itemInputs(planetItem)
+ .itemOutputs(outputItems.toArray(new ItemStack[0]))
+ .fluidInputs(
+ Materials.Hydrogen.getGas(0),
+ Materials.Helium.getGas(0),
+ MaterialsUEVplus.RawStarMatter.getFluid(0))
+ .fluidOutputs(outputFluids.toArray(new FluidStack[0]))
+ .duration(recipe.getRecipeTimeInTicks())
+ .eut(0)
+ .special(recipe)
+ .noOptimize()
+ .addTo(eyeOfHarmonyRecipes);
+ }
+ }
+
+ private void specialDeepDarkRecipe(final HashMap<String, EyeOfHarmonyRecipe> hashMap,
+ final BlockDimensionDisplay planetItem) {
+
+ HashSet<Materials> validMaterialSet = new HashSet<>();
+
+ for (Materials material : Materials.values()) {
+
+ ItemStack normalOre = GTOreDictUnificator.get(OrePrefixes.ore, material, 1);
+
+ if ((normalOre != null)) {
+ validMaterialSet.add(material);
+ }
+
+ ItemStack smallOre = GTOreDictUnificator.get(OrePrefixes.oreSmall, material, 1);
+
+ if ((smallOre != null)) {
+ validMaterialSet.add(material);
+ }
+ }
+
+ ArrayList<Materials> validMaterialList = new ArrayList<>(validMaterialSet);
+
+ long rocketTier = 9;
+
+ hashMap.put(
+ "DD",
+ new EyeOfHarmonyRecipe(
+ processDD(validMaterialList),
+ planetItem,
+ 0.6 + rocketTier / 10.0,
+ BILLION * (rocketTier + 1),
+ BILLION * (rocketTier + 1),
+ timeCalculator(rocketTier),
+ rocketTier, // -1 so that we avoid out of bounds exception on NEI render.
+ 1.0 - rocketTier * CHANCE_DECREASE_PER_DIMENSION));
+ }
+
+ private static long timeCalculator(final long rocketTier) {
+ return (long) (18_000L * pow(1.4, rocketTier));
+ }
+
+ private ArrayList<Pair<Materials, Long>> processDD(final ArrayList<Materials> validMaterialList) {
+ EyeOfHarmonyRecipe.HashMapHelper outputMap = new EyeOfHarmonyRecipe.HashMapHelper();
+
+ // 10 from rocketTier + 1, 6 * 64 = VM3 + Og, 1.4 = time increase per tier.
+ double mainMultiplier = (timeCalculator(10) * (6 * 64));
+ double probability = 1.0 / validMaterialList.size();
+
+ validMaterialList.forEach((material) -> { processHelper(outputMap, material, mainMultiplier, probability); });
+
+ ArrayList<Pair<Materials, Long>> outputList = new ArrayList<>();
+
+ outputMap.forEach((material, quantity) -> outputList.add(Pair.of(material, (long) Math.floor(quantity))));
+
+ return outputList;
+ }
+}