diff options
| author | GDCloud <93287602+GDCloudstrike@users.noreply.github.com> | 2023-11-23 01:06:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-23 00:06:56 +0000 |
| commit | 804678d5f7e20ab0c5bacc9d00c4d76a30c6701c (patch) | |
| tree | 40686b22071368923145f4b7c1cfb8adb105bc6a | |
| parent | 5bee46df394e18a697749bc32bcae71c9a6b24c7 (diff) | |
| download | GT5-Unofficial-804678d5f7e20ab0c5bacc9d00c4d76a30c6701c.tar.gz GT5-Unofficial-804678d5f7e20ab0c5bacc9d00c4d76a30c6701c.tar.bz2 GT5-Unofficial-804678d5f7e20ab0c5bacc9d00c4d76a30c6701c.zip | |
Fixing the EOH OC situation (#256)
* tooltip changes
* typo
* return to old formula and switch to bigint
* add new item + texture
* actually load the item
* power formulas
* start on stellar plasma integration
* rework math
* make static
* grammar
* spotless
* astral array fabricator recipe
* tooltip work
* adjust recipe
* fix build errors
* address reviews
* FluidStackLong
* more long fluid stack stuff
* fix nei fluid amounts
* add brackets
* undo wildcard import
* rework loop for checking aaf amount
* wrong nbt tag
* address reviews v2
11 files changed, 398 insertions, 105 deletions
diff --git a/src/main/java/com/github/technus/tectech/loader/recipe/ResearchStationAssemblyLine.java b/src/main/java/com/github/technus/tectech/loader/recipe/ResearchStationAssemblyLine.java index a58cbbe72b..1dd36e0ed6 100644 --- a/src/main/java/com/github/technus/tectech/loader/recipe/ResearchStationAssemblyLine.java +++ b/src/main/java/com/github/technus/tectech/loader/recipe/ResearchStationAssemblyLine.java @@ -5,6 +5,7 @@ import static com.google.common.math.LongMath.pow; import static gregtech.api.enums.Mods.*; import static gregtech.api.util.GT_ModHandler.getModItem; import static gregtech.api.util.GT_RecipeBuilder.MINUTES; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; @@ -3022,6 +3023,34 @@ public class ResearchStationAssemblyLine implements Runnable { (int) TierEU.RECIPE_UMV); } + // Astral Array Fabricator + TT_recipeAdder.addResearchableAssemblylineRecipe( + CustomItemList.SpacetimeCompressionFieldGeneratorTier8.get(1), + 480_000_000, + 32_768, + (int) TierEU.RECIPE_MAX, + 64, + new Object[] { GT_OreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.WhiteDwarfMatter, 8), + GT_OreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.BlackDwarfMatter, 8), + ItemList.EnergisedTesseract.get(32), + GT_OreDictUnificator.get(OrePrefixes.nanite, MaterialsUEVplus.Eternity, 16), + CustomItemList.SpacetimeCompressionFieldGeneratorTier8.get(64), + CustomItemList.SpacetimeCompressionFieldGeneratorTier8.get(64), + CustomItemList.SpacetimeCompressionFieldGeneratorTier8.get(10), + CustomItemList.TimeAccelerationFieldGeneratorTier8.get(64), + CustomItemList.TimeAccelerationFieldGeneratorTier8.get(64), + CustomItemList.TimeAccelerationFieldGeneratorTier8.get(40), + CustomItemList.StabilisationFieldGeneratorTier8.get(48), + CustomItemList.EOH_Infinite_Energy_Casing.get(32), + CustomItemList.EOH_Reinforced_Temporal_Casing.get(64), + CustomItemList.EOH_Reinforced_Spatial_Casing.get(64), ItemList.Field_Generator_UMV.get(16) }, + new FluidStack[] { MaterialsUEVplus.Space.getMolten(32_768L * 64), + MaterialsUEVplus.Eternity.getMolten(16_384L * 64), + MaterialsUEVplus.ExcitedDTSC.getFluid(8_192L * 64) }, + CustomItemList.astralArrayFabricator.get(1), + 300 * SECONDS, + (int) TierEU.RECIPE_UXV); + } private void addWirelessEnergyRecipes() { diff --git a/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java b/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java index d1a1a135db..af383a18e8 100644 --- a/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java @@ -13,6 +13,7 @@ import com.github.technus.tectech.thing.casing.SpacetimeCompressionFieldCasing; import com.github.technus.tectech.thing.casing.StabilisationFieldCasing; import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.casing.TimeAccelerationFieldCasing; +import com.github.technus.tectech.thing.item.AstralArrayFabricator; import com.github.technus.tectech.thing.item.EnderFluidLinkCover; import com.github.technus.tectech.thing.item.EuMeterGT; import com.github.technus.tectech.thing.item.ParametrizerMemoryCard; @@ -75,6 +76,7 @@ public class ThingsLoader implements Runnable { TecTech.LOGGER.info("Useful Items registered"); TeslaCoilComponent.run(); + AstralArrayFabricator.run(); TecTech.LOGGER.info("Crafting Components registered"); TecTech.LOGGER.info("Debug Items registered"); 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 d217fe7db1..5447799afb 100644 --- a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java +++ b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java @@ -21,6 +21,7 @@ import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.tuple.Pair; +import com.github.technus.tectech.util.FluidStackLong; import com.github.technus.tectech.util.ItemStackLong; import gnu.trove.map.TMap; @@ -37,12 +38,17 @@ import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper; @SuppressWarnings("SpellCheckingInspection") public class EyeOfHarmonyRecipe { - static final FluidStack[] SPECIAL_FLUIDS = new FluidStack[] { MaterialsUEVplus.WhiteDwarfMatter.getMolten(1152), - MaterialsUEVplus.WhiteDwarfMatter.getMolten(1152), MaterialsUEVplus.WhiteDwarfMatter.getMolten(4_608), - MaterialsUEVplus.WhiteDwarfMatter.getMolten(18_432), MaterialsUEVplus.BlackDwarfMatter.getMolten(1152), - MaterialsUEVplus.BlackDwarfMatter.getMolten(4_608), MaterialsUEVplus.BlackDwarfMatter.getMolten(18_432), - MaterialsUEVplus.Universium.getMolten(1152), MaterialsUEVplus.Universium.getMolten(4_608), - MaterialsUEVplus.Universium.getMolten(18_432) }; + static final FluidStackLong[] SPECIAL_FLUIDS = new FluidStackLong[] { + new FluidStackLong(MaterialsUEVplus.WhiteDwarfMatter.getMolten(1_152), 1_152), + new FluidStackLong(MaterialsUEVplus.WhiteDwarfMatter.getMolten(1_152), 1_152), + new FluidStackLong(MaterialsUEVplus.WhiteDwarfMatter.getMolten(4_608), 4_608), + new FluidStackLong(MaterialsUEVplus.WhiteDwarfMatter.getMolten(18_432), 18_432), + new FluidStackLong(MaterialsUEVplus.BlackDwarfMatter.getMolten(1_152), 1_152), + new FluidStackLong(MaterialsUEVplus.BlackDwarfMatter.getMolten(4_608), 4_608), + new FluidStackLong(MaterialsUEVplus.BlackDwarfMatter.getMolten(18_432), 18_432), + new FluidStackLong(MaterialsUEVplus.Universium.getMolten(1_152), 1_152), + new FluidStackLong(MaterialsUEVplus.Universium.getMolten(4_608), 4_608), + new FluidStackLong(MaterialsUEVplus.Universium.getMolten(18_432), 18_432) }; HashingStrategy<ItemStack> itemStackHashingStrategy = new HashingStrategy<>() { @@ -66,7 +72,7 @@ public class EyeOfHarmonyRecipe { private final TMap<ItemStack, Long> itemStackToTrueStackSizeMap = new TCustomHashMap<>(itemStackHashingStrategy); private final ArrayList<ItemStackLong> outputItems; - private final ArrayList<FluidStack> outputFluids; + private final ArrayList<FluidStackLong> outputFluids; private final long hydrogenRequirement; private final long heliumRequirement; @@ -137,25 +143,29 @@ public class EyeOfHarmonyRecipe { // End item processing. // --- Fluid handling --- - ArrayList<FluidStack> fluidStackArrayList = new ArrayList<>(); + ArrayList<FluidStackLong> fluidStackLongArrayList = new ArrayList<>(); + + int plasmaAmount = (int) ((this.spacetimeCasingTierRequired + 1) * 8_000_000L); // If DeepDark then it should output all plasmas involved in making exotic catalyst. if (rocketTier == 9) { for (Materials material : VALID_PLASMAS) { - fluidStackArrayList.add(material.getPlasma(1)); + fluidStackLongArrayList.add(new FluidStackLong(material.getPlasma(plasmaAmount), plasmaAmount)); } } else { // --- Output and process fluids of the recipe. - fluidStackArrayList.addAll(validPlasmaGenerator(materialList)); - } - - for (FluidStack fluidStack : fluidStackArrayList) { - fluidStack.amount = (int) ((this.spacetimeCasingTierRequired + 1) * 8_000_000L); + ArrayList<FluidStack> fluidStackArrayList = new ArrayList<>(validPlasmaGenerator(materialList)); + for (FluidStack fluidStack : fluidStackArrayList) { + fluidStack = new FluidStack(fluidStack, plasmaAmount); + fluidStackLongArrayList.add(new FluidStackLong(fluidStack, plasmaAmount)); + } } // Add a bonus fluid of compressed star matter. - fluidStackArrayList - .add(MaterialsUEVplus.RawStarMatter.getFluid((this.spacetimeCasingTierRequired + 1) * 100_000)); + fluidStackLongArrayList.add( + new FluidStackLong( + MaterialsUEVplus.RawStarMatter.getFluid((this.spacetimeCasingTierRequired + 1) * 100_000), + (this.spacetimeCasingTierRequired + 1) * 100_000)); // Tier 0 & 1 - 576 White // Tier 2 - 2304 White @@ -172,9 +182,9 @@ public class EyeOfHarmonyRecipe { if (spacetimeTier == 0 || spacetimeTier == 9) { spacetimeTier -= 1; } - fluidStackArrayList.add(SPECIAL_FLUIDS[spacetimeTier + 1]); + fluidStackLongArrayList.add(SPECIAL_FLUIDS[spacetimeTier + 1]); - outputFluids = fluidStackArrayList; + outputFluids = fluidStackLongArrayList; // --- End fluid handling ---. this.hydrogenRequirement = hydrogenRequirement; @@ -288,14 +298,14 @@ public class EyeOfHarmonyRecipe { } // Deep copy. - public FluidStack[] getOutputFluids() { - ArrayList<FluidStack> copyOutputList = new ArrayList<>(); + public ArrayList<FluidStackLong> getOutputFluids() { + ArrayList<FluidStackLong> copyOutputList = new ArrayList<>(); - for (FluidStack fluidStack : outputFluids) { - copyOutputList.add(fluidStack.copy()); + for (FluidStackLong fluidStackLong : outputFluids) { + copyOutputList.add(new FluidStackLong(fluidStackLong)); } - return copyOutputList.toArray(new FluidStack[0]); + return copyOutputList; } public long getHydrogenRequirement() { @@ -428,12 +438,13 @@ public class EyeOfHarmonyRecipe { return dustList; } - private static long plasmaCostCalculator(ArrayList<FluidStack> plasmas) { + private static long plasmaCostCalculator(ArrayList<FluidStackLong> plasmas) { long total = 0; - for (FluidStack plasma : plasmas) { + for (FluidStackLong plasma : plasmas) { + FluidStack plasmaFluid = plasma.getRegularFluidStack(plasma, 1); try { - String plasmaName = plasma.getFluid().getUnlocalizedName(); + String plasmaName = plasmaFluid.getFluid().getUnlocalizedName(); total += plasmaEnergyMap.getOrDefault(plasmaName, 0L) * plasma.amount; } catch (Exception e) { e.printStackTrace(); 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 372d26a0bd..8aa801e153 100644 --- a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java +++ b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java @@ -10,9 +10,11 @@ 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.github.technus.tectech.util.FluidStackLong; import com.github.technus.tectech.util.ItemStackLong; import com.google.common.math.LongMath; @@ -99,6 +101,11 @@ public class EyeOfHarmonyRecipeStorage { 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; @@ -109,7 +116,7 @@ public class EyeOfHarmonyRecipeStorage { recipe, null, null, - recipe.getOutputFluids(), + outputFluids.toArray(new FluidStack[0]), (int) recipe.getRecipeTimeInTicks(), 0, 0); diff --git a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java index 1fe7365757..6f19d13a24 100644 --- a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java +++ b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java @@ -429,7 +429,9 @@ public enum CustomItemList implements IItemContainer { StabilisationFieldGeneratorTier5, StabilisationFieldGeneratorTier6, StabilisationFieldGeneratorTier7, - StabilisationFieldGeneratorTier8; + StabilisationFieldGeneratorTier8, + + astralArrayFabricator; private ItemStack mStack; private boolean mHasNotBeenSet = true; diff --git a/src/main/java/com/github/technus/tectech/thing/item/AstralArrayFabricator.java b/src/main/java/com/github/technus/tectech/thing/item/AstralArrayFabricator.java new file mode 100644 index 0000000000..04d55442c7 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/AstralArrayFabricator.java @@ -0,0 +1,53 @@ +package com.github.technus.tectech.thing.item; + +import static com.github.technus.tectech.Reference.MODID; +import static com.github.technus.tectech.TecTech.creativeTabTecTech; +import static com.github.technus.tectech.thing.CustomItemList.astralArrayFabricator; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class AstralArrayFabricator extends Item { + + public static AstralArrayFabricator INSTANCE; + + private AstralArrayFabricator() { + setHasSubtypes(false); + setUnlocalizedName("tm.itemAstralArrayFabricator"); + setTextureName(MODID + ":itemAstralArray"); + setCreativeTab(creativeTabTecTech); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List<String> aList, boolean boo) { + aList.add(EnumChatFormatting.GRAY + translateToLocal("item.tm.itemAstralArrayFabricator.desc1")); + aList.add(EnumChatFormatting.GRAY + translateToLocal("item.tm.itemAstralArrayFabricator.desc2")); + aList.add(EnumChatFormatting.GRAY + translateToLocal("item.tm.itemAstralArrayFabricator.desc3")); + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("item.tm.itemAstralArrayFabricator.desc0")); + } + + public static void run() { + INSTANCE = new AstralArrayFabricator(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + astralArrayFabricator.set(INSTANCE); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(getIconString()); + } + +} 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 ec251dc94a..5f39421f3f 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 @@ -1,6 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import static com.github.technus.tectech.TecTech.eyeOfHarmonyRecipeStorage; +import static com.github.technus.tectech.thing.CustomItemList.astralArrayFabricator; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.eyeOfHarmonyRenderBlock; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsBA0; @@ -17,6 +18,7 @@ import static gregtech.api.util.GT_Utility.formatNumbers; import static java.lang.Math.*; import static net.minecraft.util.EnumChatFormatting.*; +import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -31,6 +33,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MathHelper; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; @@ -43,6 +46,7 @@ import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.FluidStackLong; import com.github.technus.tectech.util.ItemStackLong; import com.google.common.collect.ImmutableList; import com.google.common.math.LongMath; @@ -78,7 +82,7 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl private static final long MOLTEN_SPACETIME_PER_FAILURE_TIER = 14_400L; private static final double SPACETIME_FAILURE_BASE = 2; private static final String TOOLTIP_BAR = GOLD - + "------------------------------------------------------------------------------------"; + + "---------------------------------------------------------------------------------------"; // Region variables. private static Textures.BlockIcons.CustomIcon ScreenOFF; @@ -92,13 +96,13 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl private static final double TIME_ACCEL_DECREASE_CHANCE_PER_TIER = 0.1; // % Increase in recipe chance and % decrease in yield per tier. private static final double STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER = 0.05; - private static final double LOG_BASE_CONSTANT = Math.log(4.4); - + private static final double LOG_CONSTANT = Math.log(1.7); + private static final double PARALLEL_MULTIPLIER_CONSTANT = 1.6 * 2 + 0.019 * Math.pow(2, 1.5); + private static final long POWER_DIVISION_CONSTANT = 18; private static final int TOTAL_CASING_TIERS_WITH_POWER_PENALTY = 8; private String userUUID = ""; - private long euOutput = 0; - + private BigInteger outputEU_BigInt = BigInteger.ZERO; private long startEU = 0; @Override @@ -741,43 +745,52 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl private double hydrogenOverflowProbabilityAdjustment; private double heliumOverflowProbabilityAdjustment; + private double stellarPlasmaOverflowProbabilityAdjustment; private static final long TICKS_BETWEEN_HATCH_DRAIN = EOH_DEBUG_MODE ? 10 : 20; private List<ItemStackLong> outputItems = new ArrayList<>(); + private List<FluidStackLong> outputFluids = new ArrayList<>(); - private void calculateHydrogenHeliumInputExcessValues(final long hydrogenRecipeRequirement, + private void calculateInputFluidExcessValues(final long hydrogenRecipeRequirement, final long heliumRecipeRequirement) { double hydrogenStored = validFluidMap.get(Materials.Hydrogen.getGas(1L)); double heliumStored = validFluidMap.get(Materials.Helium.getGas(1L)); + double stellarPlasmaStored = validFluidMap.get(MaterialsUEVplus.RawStarMatter.getFluid(1L)); double hydrogenExcessPercentage = hydrogenStored / hydrogenRecipeRequirement - 1; double heliumExcessPercentage = heliumStored / heliumRecipeRequirement - 1; + double stellarPlasmaExcessPercentage = stellarPlasmaStored + / (heliumRecipeRequirement * (9 / 1_000_000f) * parallelAmount) - 1; hydrogenOverflowProbabilityAdjustment = 1 - exp(-pow(30 * hydrogenExcessPercentage, 2)); heliumOverflowProbabilityAdjustment = 1 - exp(-pow(30 * heliumExcessPercentage, 2)); + stellarPlasmaOverflowProbabilityAdjustment = 1 - exp(-pow(30 * stellarPlasmaExcessPercentage, 2)); } private double recipeChanceCalculator() { double chance = currentRecipe.getBaseRecipeSuccessChance() - timeAccelerationFieldMetadata * TIME_ACCEL_DECREASE_CHANCE_PER_TIER - + stabilisationFieldMetadata * STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER - - hydrogenOverflowProbabilityAdjustment - - heliumOverflowProbabilityAdjustment; + + stabilisationFieldMetadata * STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER; - return clamp(chance, 0.0, 1.0); - } + if (parallelAmount > 1) { + chance -= stellarPlasmaOverflowProbabilityAdjustment; + } else { + chance -= (hydrogenOverflowProbabilityAdjustment + heliumOverflowProbabilityAdjustment); + } - public static double clamp(double amount, double min, double max) { - return Math.max(min, Math.min(amount, max)); + return MathHelper.clamp_double(chance, 0.0, 1.0); } private double recipeYieldCalculator() { - double yield = 1.0 - hydrogenOverflowProbabilityAdjustment - - heliumOverflowProbabilityAdjustment - - stabilisationFieldMetadata * STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER; + double yield = 1.0 - stabilisationFieldMetadata * STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER; - return clamp(yield, 0.0, 1.0); + if (parallelAmount > 1) { + yield -= stellarPlasmaOverflowProbabilityAdjustment; + } else { + yield -= (hydrogenOverflowProbabilityAdjustment + heliumOverflowProbabilityAdjustment); + } + return MathHelper.clamp_double(yield, 0.0, 1.0); } private int recipeProcessTimeCalculator(final long recipeTime, final long recipeSpacetimeCasingRequired) { @@ -950,13 +963,8 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl "is available the items/fluids will be " + UNDERLINE + DARK_RED + "voided" + RESET + GRAY + ".") .addInfo(TOOLTIP_BAR) .addInfo("This multiblock can be overclocked by placing a programmed circuit into the input bus.") - .addInfo("Each OC halves recipe time and multiplies startup cost by a factor of:") - .addInfo(GREEN + "(log4.4(overclockAmount + 1) + 1) * 0.77^overclockAmount") .addInfo( - "Furthermore, each OC decreases the power output by a factor of " + RED - + "0.77^overclockAmount" - + GRAY - + ".") + "E.g. A circuit of 2 will provide 2 OCs, 16x EU consumed and 0.25x the time. All outputs are equal.") .addInfo("All item and fluid output chances & amounts per recipe are unaffected.").addInfo(TOOLTIP_BAR) .addInfo( "If a recipe fails the EOH will output " + GREEN @@ -970,6 +978,25 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl .addInfo( MaterialsUEVplus.SpaceTime.getLocalizedNameForItem("%material") + " instead of fluid/item outputs and output as much EU as a successful recipe.") + .addInfo(TOOLTIP_BAR) + .addInfo( + "This multiblock can perform parallel processing by placing Astral Array Fabricators into the input bus.") + .addInfo("The amount of parallel is calculated via this formula:") + .addInfo(GREEN + "parallel = 2^(floor(log(8 * astralArrayAmount) / log(1.7)))") + .addInfo("If the EOH is running parallel recipes, the power calculation changes.") + .addInfo("The power needed for parallel processing is calculated as follows:") + .addInfo( + GREEN + "total EU = ((powerOutput * 2 - powerInput * (3.2 + 0.019 * 2^(1.5))) / 18) * 2.3^(log2(parallel) - 1)") + .addInfo( + "Furthermore, if parallel recipes are run, the recipes consume " + + MaterialsUEVplus.RawStarMatter.getLocalizedNameForItem("%material")) + .addInfo("instead of helium and hydrogen. Overflow penalties still apply.") + .addInfo( + "The required amount of fluid to start a recipe is " + GREEN + + "9 / 10^6 * heliumAmount * parallel" + + GRAY + + ".") + .addInfo("All item & fluid outputs including failure fluid are multiplied by the amount of parallel.") .addInfo(TOOLTIP_BAR).addInfo("Animations can be disabled by using a screwdriver on the multiblock.") .addSeparator().addStructureInfo("Eye of Harmony structure is too complex! See schematic for details.") .addStructureInfo( @@ -1035,6 +1062,7 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl { put(Materials.Hydrogen.getGas(1), 0L); put(Materials.Helium.getGas(1), 0L); + put(MaterialsUEVplus.RawStarMatter.getFluid(1), 0L); } }; @@ -1064,6 +1092,9 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl // Check for recipe every recipeCheckInterval ticks. private static final long RECIPE_CHECK_INTERVAL = 3 * 20; private long currentCircuitMultiplier = 0; + private long astralArrayAmount = 0; + private long parallelAmount = 1; + private BigInteger usedEU = BigInteger.ZERO; @Override @NotNull @@ -1101,23 +1132,55 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl return validFluidMap.get(Materials.Helium.getGas(1)); } + private long getStellarPlasmaStored() { + return validFluidMap.get(MaterialsUEVplus.RawStarMatter.getFluid(1)); + } + public CheckRecipeResult processRecipe(EyeOfHarmonyRecipe recipeObject) { // Get circuit damage, clamp it and then use it later for overclocking. for (ItemStack itemStack : mInputBusses.get(0).getRealInventory()) { if (GT_Utility.isAnyIntegratedCircuit(itemStack)) { - currentCircuitMultiplier = (long) clamp(itemStack.getItemDamage(), 0, 24); + currentCircuitMultiplier = MathHelper.clamp_int(itemStack.getItemDamage(), 0, 24); break; } } + astralArrayAmount = 0; + + for (ItemStack itemStack : mInputBusses.get(0).getRealInventory()) { + if (itemStack != null && itemStack.isItemEqual(astralArrayFabricator.get(1))) { + astralArrayAmount += itemStack.stackSize; + } + } + + long parallelExponent = 1; + + if (astralArrayAmount != 0) { + parallelExponent = (long) Math.floor(Math.log(8 * astralArrayAmount) / LOG_CONSTANT); + parallelAmount = (long) pow(2, parallelExponent); + } else { + parallelAmount = 1; + } + // Debug mode, overwrites the required fluids to initiate the recipe to 100L of each. - if ((EOH_DEBUG_MODE && getHydrogenStored() < 100) - || (getHydrogenStored() < currentRecipe.getHydrogenRequirement())) { - return SimpleCheckRecipeResult.ofFailure("no_hydrogen"); + if (parallelAmount > 1) { + if ((EOH_DEBUG_MODE && getStellarPlasmaStored() < 100) || (!EOH_DEBUG_MODE && getStellarPlasmaStored() + < currentRecipe.getHeliumRequirement() * (9 / 1_000_000f) * parallelAmount)) { + return SimpleCheckRecipeResult.ofFailure("no_stellarPlasma"); + } } - if ((EOH_DEBUG_MODE && getHeliumStored() < 100) || (getHeliumStored() < currentRecipe.getHeliumRequirement())) { - return SimpleCheckRecipeResult.ofFailure("no_helium"); + + if (parallelAmount == 1) { + if ((EOH_DEBUG_MODE && getHydrogenStored() < 100) || (!EOH_DEBUG_MODE + && getHydrogenStored() < currentRecipe.getHydrogenRequirement() * parallelAmount)) { + return SimpleCheckRecipeResult.ofFailure("no_hydrogen"); + } + + if ((EOH_DEBUG_MODE && getHeliumStored() < 100) + || (!EOH_DEBUG_MODE && getHeliumStored() < currentRecipe.getHeliumRequirement() * parallelAmount)) { + return SimpleCheckRecipeResult.ofFailure("no_helium"); + } } if (spacetimeCompressionFieldMetadata == -1) { @@ -1131,37 +1194,60 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl .insufficientMachineTier((int) recipeObject.getSpacetimeCasingTierRequired()); } + // Calculate multipliers used in power calculations + double powerMultiplier = Math.max(1, Math.pow(2.3, (parallelExponent - 1))); + long precisionMultiplier = (long) Math.pow(10, parallelExponent - 1); + + // Determine EU recipe input startEU = recipeObject.getEUStartCost(); + // Determine EU recipe output + outputEU_BigInt = BigInteger.valueOf(recipeObject.getEUOutput()); + + double multiplier = 1; + + // Calculate actual EU values + if (parallelAmount > 1) { + multiplier = PARALLEL_MULTIPLIER_CONSTANT / POWER_DIVISION_CONSTANT; + outputEU_BigInt = outputEU_BigInt + .multiply( + BigInteger.valueOf( + (long) (1 - ((TOTAL_CASING_TIERS_WITH_POWER_PENALTY - stabilisationFieldMetadata) + * STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER)) * 100)) + .divide(BigInteger.valueOf(9 * 100)) + .multiply(BigInteger.valueOf((long) (powerMultiplier * precisionMultiplier))) + .divide(BigInteger.valueOf(precisionMultiplier)); + } + usedEU = BigInteger.valueOf((long) (-startEU * multiplier)) + .multiply( + BigInteger.valueOf((long) Math.pow(4, currentCircuitMultiplier)) + .multiply(BigInteger.valueOf((long) (powerMultiplier * precisionMultiplier)))) + .divide(BigInteger.valueOf(precisionMultiplier)); + // Remove EU from the users network. - long usedEU = (long) (-startEU * (Math.log(currentCircuitMultiplier + 1) / LOG_BASE_CONSTANT + 1) - * pow(0.77, currentCircuitMultiplier)); if (!addEUToGlobalEnergyMap(userUUID, usedEU)) { - return CheckRecipeResultRegistry.insufficientPower(usedEU); + return SimpleCheckRecipeResult.ofFailure("insufficient_power_no_val"); } mMaxProgresstime = recipeProcessTimeCalculator( recipeObject.getRecipeTimeInTicks(), recipeObject.getSpacetimeCasingTierRequired()); - calculateHydrogenHeliumInputExcessValues( - recipeObject.getHydrogenRequirement(), - recipeObject.getHeliumRequirement()); + calculateInputFluidExcessValues(recipeObject.getHydrogenRequirement(), recipeObject.getHeliumRequirement()); if (EOH_DEBUG_MODE) { hydrogenOverflowProbabilityAdjustment = 0; heliumOverflowProbabilityAdjustment = 0; + stellarPlasmaOverflowProbabilityAdjustment = 0; } successChance = recipeChanceCalculator(); currentRecipeRocketTier = currentRecipe.getRocketTier(); - // Determine EU recipe output. - euOutput = (long) (recipeObject.getEUOutput() * pow(0.77, currentCircuitMultiplier)); - - // Reduce internal storage by hydrogen and helium quantity required for recipe. + // Reduce internal storage by input fluid quantity required for recipe. validFluidMap.put(Materials.Hydrogen.getGas(1), 0L); validFluidMap.put(Materials.Helium.getGas(1), 0L); + validFluidMap.put(MaterialsUEVplus.RawStarMatter.getFluid(1), 0L); double yield = recipeYieldCalculator(); if (EOH_DEBUG_MODE) { @@ -1169,19 +1255,17 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl } // Return copies of the output objects. - mOutputFluids = recipeObject.getOutputFluids(); + outputFluids = recipeObject.getOutputFluids(); outputItems = recipeObject.getOutputItems(); - if (yield != 1.0) { - // Iterate over item output list and apply yield values. - for (ItemStackLong itemStackLong : outputItems) { - itemStackLong.stackSize *= yield; - } + // Iterate over item output list and apply yield & parallel values. + for (ItemStackLong itemStackLong : outputItems) { + itemStackLong.stackSize *= yield * parallelAmount; + } - // Iterate over fluid output list and apply yield values. - for (FluidStack fluidStack : mOutputFluids) { - fluidStack.amount *= yield; - } + // Iterate over fluid output list and apply yield & parallel values. + for (FluidStackLong fluidStackLong : outputFluids) { + fluidStackLong.amount *= yield * parallelAmount; } updateSlots(); @@ -1230,9 +1314,10 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl private void outputFailedChance() { // 2^Tier spacetime released upon recipe failure. - mOutputFluids = new FluidStack[] { MaterialsUEVplus.SpaceTime.getMolten( + outputFluidToAENetwork( + MaterialsUEVplus.SpaceTime.getMolten(1), (long) (successChance * MOLTEN_SPACETIME_PER_FAILURE_TIER - * pow(SPACETIME_FAILURE_BASE, currentRecipeRocketTier + 1))) }; + * pow(SPACETIME_FAILURE_BASE, currentRecipeRocketTier + 1)) * parallelAmount); super.outputAfterRecipe_EM(); } @@ -1263,13 +1348,11 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl destroyRenderBlock(); - // Output power with stabilization factor (5% loss per tier below gallifreyan) - addEUToGlobalEnergyMap( - userUUID, - (long) (euOutput * (1 - ((TOTAL_CASING_TIERS_WITH_POWER_PENALTY - stabilisationFieldMetadata) - * STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER)))); + // Output EU + addEUToGlobalEnergyMap(userUUID, outputEU_BigInt); + startEU = 0; - euOutput = 0; + outputEU_BigInt |
