From b5ae11304fe9ff7cafeabbb55095fb58e17031b7 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Sun, 28 Nov 2021 19:52:44 +0000 Subject: Rewrote sparge handling to use recipe map. --- .../production/GregtechMTE_NuclearReactor.java | 100 ++++++--------------- 1 file changed, 29 insertions(+), 71 deletions(-) (limited to 'src') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java index f2b0d70d65..c13824a51a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java @@ -31,12 +31,13 @@ import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GasSpargingRecipe; +import gregtech.api.util.GasSpargingRecipeMap; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.material.ELEMENT; -import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import net.minecraft.item.ItemStack; @@ -50,6 +51,9 @@ public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase { private static Fluid mFluorine; protected int mFuelRemaining = 0; + public final static int sMinSpargeWait = 1200; + public final static int sMaxSpargeWait = 2400; + private int mCasing; private IStructureDefinition STRUCTURE_DEFINITION = null; @@ -566,80 +570,34 @@ public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase { updateSlots(); } - private static AutoMap mNobleGases; - private static AutoMap mFluorideGases; - private static AutoMap mSpargeGases; - - public final static int sMinSpargeWait = 1200; - public final static int sMaxSpargeWait = 2400; - - private AutoMap getByproductsOfSparge(final FluidStack spargeGas){ - AutoMap aOutputGases = new AutoMap(); - if (mNobleGases == null) { - mNobleGases = new AutoMap(); - mNobleGases.add(Materials.Helium.getGas(1).getFluid()); - mNobleGases.add(ELEMENT.getInstance().XENON.getFluid(1).getFluid()); - mNobleGases.add(ELEMENT.getInstance().NEON.getFluid(1).getFluid()); - mNobleGases.add(ELEMENT.getInstance().ARGON.getFluid(1).getFluid()); - mNobleGases.add(ELEMENT.getInstance().KRYPTON.getFluid(1).getFluid()); - mNobleGases.add(ELEMENT.getInstance().RADON.getFluid(1).getFluid()); - } - if (mFluorideGases == null) { - mFluorideGases = new AutoMap(); - mFluorideGases.add(Materials.Fluorine.getGas(1).getFluid()); - mFluorideGases.add(FLUORIDES.LITHIUM_FLUORIDE.getFluid(1).getFluid()); - mFluorideGases.add(FLUORIDES.NEPTUNIUM_HEXAFLUORIDE.getFluid(1).getFluid()); - mFluorideGases.add(FLUORIDES.TECHNETIUM_HEXAFLUORIDE.getFluid(1).getFluid()); - mFluorideGases.add(FLUORIDES.SELENIUM_HEXAFLUORIDE.getFluid(1).getFluid()); - } - if (mSpargeGases == null) { - mSpargeGases = new AutoMap(); - mSpargeGases.add(Materials.Helium.getGas(1).getFluid()); - mSpargeGases.add(Materials.Fluorine.getGas(1).getFluid()); - } - if (spargeGas == null) { - return aOutputGases; + private AutoMap getByproductsOfSparge(final FluidStack spargeGas){ + GasSpargingRecipe aSpargeRecipe = null; + AutoMap aOutputGases = new AutoMap(); + for (GasSpargingRecipe aRecipe : GasSpargingRecipeMap.mRecipes) { + if (aRecipe.mInputGas.isFluidEqual(spargeGas)) { + aSpargeRecipe = aRecipe; + } } - int outputChances[] = null; - int aDepletionAmount = 0; - int aSpargeType = -1; - if (spargeGas.getFluid().equals(mHelium)){ - outputChances = new int[]{ - 0, - MathUtils.roundToClosestInt(MathUtils.randInt(0, 20)), - MathUtils.roundToClosestInt(MathUtils.randInt(0, 20)), - MathUtils.roundToClosestInt(MathUtils.randInt(0, 20)), - MathUtils.roundToClosestInt(MathUtils.randInt(0, 20)), - MathUtils.roundToClosestInt(MathUtils.randInt(0, 20)) - }; - aDepletionAmount = 100; - outputChances[0] = (aDepletionAmount-outputChances[1]-outputChances[2]-outputChances[3]-outputChances[4]-outputChances[5]); - aSpargeType = 0; - } - else if (spargeGas.getFluid().equals(mFluorine)){ - outputChances = new int[]{ - 0, - MathUtils.roundToClosestInt(MathUtils.randDouble(0, 40)), - MathUtils.roundToClosestInt(MathUtils.randDouble(0, 20)), - MathUtils.roundToClosestInt(MathUtils.randDouble(0, 20)), - MathUtils.roundToClosestInt(MathUtils.randDouble(0, 20)) - }; - aDepletionAmount = 100; - outputChances[0] = (aDepletionAmount-outputChances[1]-outputChances[2]-outputChances[3]-outputChances[4]); - aSpargeType = 1; + if (aSpargeRecipe == null) { + return aOutputGases; } - if (outputChances == null) { - return aOutputGases; + int aSpargeGasAmount = aSpargeRecipe.mInputGas.amount; + FluidStack depletionStack = aSpargeRecipe.mInputGas.copy(); + depletionStack.amount = aSpargeGasAmount; + this.depleteInput(depletionStack); + updateSlots(); + for (int i=0;i aTempMap = aSpargeType == 0 ? mNobleGases : mFluorideGases; - for (int i = 0; i < aTempMap.size(); i++) { - Fluid aFluid = aTempMap.get(i); - aOutputGases.add(new FluidStack(aFluid, outputChances[i])); + if (aSpargeGasAmount > 0) { + aOutputGases.add(new FluidStack(aSpargeRecipe.mInputGas.getFluid(), aSpargeGasAmount)); } - this.depleteInput(depletionStack); - updateSlots(); return aOutputGases; } -- cgit