aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGTNH-Colen <54497873+GTNH-Colen@users.noreply.github.com>2022-12-18 21:39:13 +0000
committerGTNH-Colen <54497873+GTNH-Colen@users.noreply.github.com>2022-12-18 21:39:13 +0000
commit2616cbc4b046dbf6a2c74b115d53148a726c61b5 (patch)
tree0d860a319d268aa3b066f8f6b2a2e4dda5bf360b
parentee76de225f16018fb9aa7a437608df2f7ee0f67c (diff)
downloadGT5-Unofficial-2616cbc4b046dbf6a2c74b115d53148a726c61b5.tar.gz
GT5-Unofficial-2616cbc4b046dbf6a2c74b115d53148a726c61b5.tar.bz2
GT5-Unofficial-2616cbc4b046dbf6a2c74b115d53148a726c61b5.zip
Working with multiple dimensions.
-rw-r--r--dependencies.gradle6
-rw-r--r--src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java62
-rw-r--r--src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java75
-rw-r--r--src/main/java/com/github/technus/tectech/thing/casing/SpacetimeCompressionFieldCasing.java14
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java39
5 files changed, 119 insertions, 77 deletions
diff --git a/dependencies.gradle b/dependencies.gradle
index dace97de85..69ca979042 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -3,18 +3,18 @@
dependencies {
shadowImplementation('com.github.GTNewHorizons:AVRcore:master-SNAPSHOT')
- compile('com.github.GTNewHorizons:GT5-Unofficial:5.09.41.141:dev')
+ compile('com.github.GTNewHorizons:GT5-Unofficial:5.09.41.178:dev')
compile('com.github.GTNewHorizons:Yamcl:0.5.82:dev')
compile('com.github.GTNewHorizons:NotEnoughItems:2.2.15-GTNH:dev')
compile('com.github.GTNewHorizons:CodeChickenLib:1.1.5.3:dev')
compile('com.github.GTNewHorizons:CodeChickenCore:1.1.4:dev')
compile('com.github.GTNewHorizons:StructureLib:1.1.7:dev')
compile('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
+ compile('com.github.GTNewHorizons:GTNEIOrePlugin:1.0.21:dev')
- // To remove
+ // To remove, for testing only.
compile('com.github.GTNewHorizons:ExtraCells2:2.5.28:dev')
compile('com.github.GTNewHorizons:AE2FluidCraft-Rework:1.0.40-gtnh:dev')
- compile('com.github.GTNewHorizons:GTNEIOrePlugin:1.0.21:dev')
compileOnly('com.github.GTNewHorizons:OpenModularTurrets:2.2.11-247:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:OpenComputers:1.7.5.23-GTNH:dev') {transitive=false}
diff --git a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java
index 0da39589ee..112e227fe8 100644
--- a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java
+++ b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java
@@ -5,18 +5,17 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import org.apache.commons.lang3.tuple.Pair;
-import org.lwjgl.Sys;
import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
+import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-public class EyeOfHarmonyRecipe {
+import static com.google.common.math.LongMath.pow;
+import static gregtech.api.enums.GT_Values.getMaxPlasmaTurbineEfficiency;
+import static gregtech.api.util.GT_Utility.getPlasmaFuelValueInEUPerLiterFromMaterial;
- private static final double maxPlasmaEfficiency = 3;
+public class EyeOfHarmonyRecipe {
private final List<Pair<ItemStack, Long>> outputItems;
private final FluidStack[] outputFluids;
@@ -31,26 +30,31 @@ public class EyeOfHarmonyRecipe {
private final long spacetimeCasingTierRequired;
- private final long miningTime;
+ private final long miningTimeSeconds;
public EyeOfHarmonyRecipe(GT5OreLayerHelper.OreDimensionWrapper dimensionWrapper,
double recipeEnergyEfficiency,
long hydrogenRequirement,
long heliumRequirement,
- long miningTime,
+ long miningTimeSeconds,
long spacetimeCasingTierRequired,
long euOutput,
double baseSuccessChance
) {
- ArrayList<Pair<Materials, Long>> materialList = processDimension(dimensionWrapper, miningTime, 6 * 64);
+ // 6 * 64 = 6 stacks/second.
+ ArrayList<Pair<Materials, Long>> materialList = processDimension(dimensionWrapper, miningTimeSeconds, 6 * 64);
this.outputItems = validDustGenerator(materialList);
this.outputFluids = validPlasmaGenerator(materialList, 0.1);
this.spacetimeCasingTierRequired = spacetimeCasingTierRequired;
- this.euStartCost = (long) (plasmaCostCalculator(this.outputFluids) * recipeEnergyEfficiency);
+ // 20 ticks, 2^19 (1A UV) eu/t, mining
+ long euOfVMRunning = miningTimeSeconds * 20 * pow(2, 19);
+ long euValueOfPlasmas = plasmaCostCalculator(this.outputFluids);
+
+ this.euStartCost = euOfVMRunning + euValueOfPlasmas;
this.euOutput = euOutput;
this.hydrogenRequirement = hydrogenRequirement;
@@ -58,8 +62,7 @@ public class EyeOfHarmonyRecipe {
this.baseSuccessChance = baseSuccessChance;
- this.miningTime = miningTime;
-
+ this.miningTimeSeconds = miningTimeSeconds;
}
public List<Pair<ItemStack, Long>> getOutputItems() {
@@ -87,7 +90,7 @@ public class EyeOfHarmonyRecipe {
}
public long getRecipeTime() {
- return miningTime;
+ return miningTimeSeconds;
}
public double getBaseRecipeSuccessChance() {
@@ -150,27 +153,27 @@ public class EyeOfHarmonyRecipe {
static FluidStack[] validPlasmaGenerator(final List<Pair<Materials, Long>> planetList, final double percentageOfPlasma) {
- List<FluidStack> plasma_list = new ArrayList<>();
+ List<FluidStack> plasmaList = new ArrayList<>();
for (Pair<Materials, Long> pair : planetList) {
if (validPlasmas.contains(pair.getLeft())) {
- plasma_list.add(pair.getLeft().getPlasma((int) (pair.getRight() * percentageOfPlasma)));
+ plasmaList.add(pair.getLeft().getPlasma((int) (pair.getRight() * percentageOfPlasma)));
}
}
- return plasma_list.toArray(new FluidStack[0]);
+ return plasmaList.toArray(new FluidStack[0]);
}
static List<Pair<ItemStack, Long>> validDustGenerator(final List<Pair<Materials, Long>> planetList) {
- List<Pair<ItemStack, Long>> dust_list = new ArrayList<>();
+ List<Pair<ItemStack, Long>> dustList = new ArrayList<>();
for (Pair<Materials, Long> pair : planetList) {
ItemStack dust = pair.getLeft().getDust(1);
if (dust != null) {
- dust_list.add(Pair.of(dust, pair.getRight()));
+ dustList.add(Pair.of(dust, pair.getRight()));
}
}
- return dust_list;
+ return dustList;
}
static long plasmaCostCalculator(FluidStack[] plasmas) {
@@ -180,7 +183,7 @@ public class EyeOfHarmonyRecipe {
total += (plasmaEnergyMap.get(plasma.getFluid()) * plasma.amount);
}
- return (long) (total * maxPlasmaEfficiency);
+ return (long) (total * getMaxPlasmaTurbineEfficiency());
}
static final List<Materials> validPlasmas = Stream.of(
@@ -202,23 +205,8 @@ public class EyeOfHarmonyRecipe {
Materials.Niobium
).collect(Collectors.toList());
- static HashMap<Fluid, Long> plasmaEnergyMap = new HashMap<Fluid, Long>() {{
- put(Materials.Helium.getPlasma(1).getFluid(), 81_920L);
- put(Materials.Boron.getPlasma(1).getFluid(), 112_640L);
- put(Materials.Nitrogen.getPlasma(1).getFluid(), 129_024L);
- put(Materials.Oxygen.getPlasma(1).getFluid(), 131_072L);
- put(Materials.Sulfur.getPlasma(1).getFluid(), 170_393L);
- put(Materials.Calcium.getPlasma(1).getFluid(), 188_416L);
- put(Materials.Titanium.getPlasma(1).getFluid(), 196_608L);
- put(Materials.Iron.getPlasma(1).getFluid(), 206_438L);
- put(Materials.Nickel.getPlasma(1).getFluid(), 213_811L);
- put(Materials.Zinc.getPlasma(1).getFluid(), 226_304L);
- put(Materials.Niobium.getPlasma(1).getFluid(), 269_516L);
- put(Materials.Silver.getPlasma(1).getFluid(), 282_685L);
- put(Materials.Tin.getPlasma(1).getFluid(), 304_496L);
- put(Materials.Americium.getPlasma(1).getFluid(), 501_760L);
- put(Materials.Radon.getPlasma(1).getFluid(), 450_560L);
- put(Materials.Bismuth.getPlasma(1).getFluid(), 425_984L);
+ static HashMap<Fluid, Long> plasmaEnergyMap = new HashMap<Fluid, Long>() {{
+ validPlasmas.forEach((material -> put(material.getPlasma(1).getFluid(), (long) getPlasmaFuelValueInEUPerLiterFromMaterial(material))));
}};
}
diff --git a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java
index 9d490168e4..4c2255a5f4 100644
--- a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java
+++ b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java
@@ -1,23 +1,66 @@
package com.github.technus.tectech.recipe;
-import static com.google.common.math.IntMath.pow;
+import com.google.common.math.LongMath;
+import gregtech.api.GregTech_API;
+import net.minecraft.block.Block;
+import net.minecraft.item.ItemStack;
+import org.lwjgl.Sys;
+import pers.gwyog.gtneioreplugin.plugin.block.BlockDimensionDisplay;
+import pers.gwyog.gtneioreplugin.plugin.block.ModBlocks;
+import pers.gwyog.gtneioreplugin.util.DimensionHelper;
+
+import java.util.HashMap;
+
import static pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper.dimToOreWrapper;
public class EyeOfHarmonyRecipeStorage {
-// static final long MILLION = pow(10, 6); // Fix, these take int, not long, overflow occurring.
-// static final long BILLION = pow(10, 9);
-// static final long TRILLION = pow(10, 12);
-// static final long QUADRILLION = pow(10, 15);
-// static final long QUINTILLION = pow(10, 18);
- static final long SEXTILLION = pow(10, 21);
-
- public EyeOfHarmonyRecipe overworld = new EyeOfHarmonyRecipe(dimToOreWrapper.get("Ow"),
- 1.0,
- 100,
- 100,
- 36_000L,
- 0,
- 100 * 10,
- 0.4);
+// static final long MILLION = LongMath.pow(10, 6);
+// static final long BILLION = LongMath.pow(10, 9);
+// static final long TRILLION = LongMath.pow(10, 12);
+// static final long QUADRILLION = LongMath.pow(10, 15);
+// static final long QUINTILLION = LongMath.pow(10, 18);
+// static final long SEXTILLION = LongMath.pow(10, 21);
+
+ // Map is unique so this is fine.
+ HashMap<Block, String> blocksMapInverted = new HashMap<Block, String>() {{
+ ModBlocks.blocks.forEach((dimString, dimBlock) -> {
+ put(dimBlock, dimString);
+ });
+ }};
+
+ private final HashMap<String, EyeOfHarmonyRecipe> recipeHashMap = new HashMap<String, EyeOfHarmonyRecipe>() {{
+ for (String dimAbbreviation : DimensionHelper.DimNameDisplayed) {
+ BlockDimensionDisplay a = (BlockDimensionDisplay) ModBlocks.blocks.get(dimAbbreviation);
+
+ try {
+ put(dimAbbreviation, new EyeOfHarmonyRecipe(
+ dimToOreWrapper.get(dimAbbreviation),
+ 1.0,
+ 100,
+ 100,
+ 36_000L,
+ 0,
+ 100 * 10,
+ 0.4));
+ } catch(Exception e) {
+ e.printStackTrace();
+ System.out.println(dimAbbreviation + " dimension not found in dimToOreWrapper");
+ }
+ }
+ }};
+
+ public EyeOfHarmonyRecipe recipeLookUp(ItemStack aStack) {
+ String dimAbbreviation = blocksMapInverted.get(Block.getBlockFromItem(aStack.getItem()));
+ return recipeHashMap.get(dimAbbreviation);
+ }
+
+// public EyeOfHarmonyRecipe overworld = new EyeOfHarmonyRecipe(dimToOreWrapper.get("Ow"),
+// 1.0,
+// 100,
+// 100,
+// 36_000L,
+// 0,
+// 100 * 10,
+// 0.4);
}
diff --git a/src/main/java/com/github/technus/tectech/thing/casing/SpacetimeCompressionFieldCasing.java b/src/main/java/com/github/technus/tectech/thing/casing/SpacetimeCompressionFieldCasing.java
index acbf6ad9d8..92ec8ae390 100644
--- a/src/main/java/com/github/technus/tectech/thing/casing/SpacetimeCompressionFieldCasing.java
+++ b/src/main/java/com/github/technus/tectech/thing/casing/SpacetimeCompressionFieldCasing.java
@@ -33,13 +33,13 @@ public class SpacetimeCompressionFieldCasing extends GT_Block_Casings_Abstract {
Textures.BlockIcons.casingTexturePages[texturePage][b + START_INDEX] = new GT_CopiedBlockTexture(this, 6, b);
}
- GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "TEST Crude Spacetime Compression Field Generator");
- GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "TEST Primitive Spacetime Compression Field Generator");
- GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "TEST Stable Spacetime Compression Field Generator");
- GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "TEST Superb Spacetime Compression Field Generator");
- GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "TEST Resplendent Spacetime Compression Field Generator");
- GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "TEST Perfect Spacetime Compression Field Generator");
- GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "TEST Tipler Grade Spacetime Compression Field Generator");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Crude Spacetime Compression Field Generator");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Primitive Spacetime Compression Field Generator");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Stable Spacetime Compression Field Generator");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Superb Spacetime Compression Field Generator");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Resplendent Spacetime Compression Field Generator");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Perfect Spacetime Compression Field Generator");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Tipler Grade Spacetime Compression Field Generator");
CustomItemList.SpacetimeCompressionFieldGeneratorTier0.set(new ItemStack(this, 1, 0));
CustomItemList.SpacetimeCompressionFieldGeneratorTier1.set(new ItemStack(this, 1, 1));
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java
index 3772f7e82f..4c02edf46e 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java
@@ -43,7 +43,6 @@ import static gregtech.api.enums.GT_Values.AuthorColen;
import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional;
import static java.lang.Math.*;
import static net.minecraft.util.EnumChatFormatting.*;
-import static pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper.dimToOreWrapper;
@SuppressWarnings("SpellCheckingInspection")
public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable, IGlobalWirelessEnergy {
@@ -57,8 +56,8 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl
private int TimeAccelerationFieldMetadata = -1;
private int StabilisationFieldMetadata = -1;
- private String user_uuid = "";
- private String user_name = "";
+ private String userUUID = "";
+ private String userName = "";
private long euOutput = 0;
private final long[] computationStack = new long[computationTickCacheSize];
@@ -395,28 +394,40 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl
}
}
+ EyeOfHarmonyRecipe currentRecipeObject;
+
@Override
public boolean checkRecipe_EM(ItemStack aStack) {
- long hydrogen_stored = validFluidMap.get(Materials.Hydrogen.getGas(1));
- long helium_stored = validFluidMap.get(Materials.Helium.getGas(1));
-
- if ((hydrogen_stored >= recipes.overworld.getHydrogenRequirement()) & (helium_stored >= recipes.overworld.getHeliumRequirement())) {
- return processRecipe(recipes.overworld);
+ currentRecipeObject = recipes.recipeLookUp(aStack);
+ if (processRecipe(currentRecipeObject)) {
+ return true;
}
-
+ currentRecipeObject = null;
return false;
}
+ private long getHydrogenStored() {
+ return validFluidMap.get(Materials.Hydrogen.getGas(1));
+ }
+
+ private long getHeliumStored() {
+ return validFluidMap.get(Materials.Helium.getGas(1));
+ }
+
public boolean processRecipe(EyeOfHarmonyRecipe recipeObject) {
+ if ((getHydrogenStored() < currentRecipeObject.getHydrogenRequirement()) & (getHeliumStored() < currentRecipeObject.getHeliumRequirement())) {
+ return false;
+ }
+
// Check tier of spacetime compression blocks is high enough.
if (SpacetimeCompressionFieldMetadata <= recipeObject.getSpacetimeCasingTierRequired()) {
return false;
}
// Remove EU from the users network.
- if (!addEUToGlobalEnergyMap(user_uuid, -recipeObject.getEUStartCost())) {
+ if (!addEUToGlobalEnergyMap(userUUID, -recipeObject.getEUStartCost())) {
return false;
}
@@ -481,7 +492,7 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl
return;
}
- addEUToGlobalEnergyMap(user_uuid, euOutput);
+ addEUToGlobalEnergyMap(userUUID, euOutput);
euOutput = 0;
for (Pair<ItemStack, Long> itemPair : output_items) {
@@ -504,9 +515,9 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl
super.onPreTick(aBaseMetaTileEntity, aTick);
if (aTick == 1) {
- user_uuid = String.valueOf(getBaseMetaTileEntity().getOwnerUuid());
- user_name = getBaseMetaTileEntity().getOwnerName();
- strongCheckOrAddUser(user_uuid, user_name);
+ userUUID = String.valueOf(getBaseMetaTileEntity().getOwnerUuid());
+ userName = getBaseMetaTileEntity().getOwnerName();
+ strongCheckOrAddUser(userUUID, userName);
// Move into tick == 1 after debug.
if (recipes == null) {