diff options
author | BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> | 2022-09-21 01:14:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-21 00:14:35 +0200 |
commit | 7272f35d31f70114568dce07810d05fa380d7d72 (patch) | |
tree | 7e665e4c9ab0c4431517b2e75aeb9567a4c9b393 /src/main | |
parent | 756663af34a90ececa4db9eb47877adec07e1bb1 (diff) | |
download | GT5-Unofficial-7272f35d31f70114568dce07810d05fa380d7d72.tar.gz GT5-Unofficial-7272f35d31f70114568dce07810d05fa380d7d72.tar.bz2 GT5-Unofficial-7272f35d31f70114568dce07810d05fa380d7d72.zip |
fixes XL bug to produce plasma and adds Steelux turbine change (#357)
* fixes XL bug to produce plasma and adds Steelux turbine change
* spotlessApply (#358)
Co-authored-by: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com>
Co-authored-by: GitHub GTNH Actions <>
* changes requested
* spotlessApply (#359)
Co-authored-by: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com>
Co-authored-by: GitHub GTNH Actions <>
* missed it, now its added
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/main')
5 files changed, 21 insertions, 126 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java index 68cfc44527..d0a7ba9da9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java @@ -62,7 +62,7 @@ public class GT_MTE_LargeTurbine_Gas extends GregtechMetaTileEntity_LargerTurbin } @Override - int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff) { + int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { if (aFluids.size() >= 1) { int tEU = 0; int actualOptimalFlow = 0; @@ -82,7 +82,7 @@ public class GT_MTE_LargeTurbine_Gas extends GregtechMetaTileEntity_LargerTurbin return GT_Utility.safeInt((long) aOptFlow * (long) aBaseEff / 10000L); } - actualOptimalFlow = GT_Utility.safeInt((long) aOptFlow / fuelValue); + actualOptimalFlow = GT_Utility.safeInt((long) (aOptFlow * (double) flowMultipliers[1] / fuelValue)); this.realOptFlow = actualOptimalFlow; int remainingFlow = GT_Utility.safeInt((long) (actualOptimalFlow diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java index 517c32441a..f856e4ba95 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java @@ -3,13 +3,10 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.t import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Turbine; import java.util.ArrayList; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidRegistry; @@ -63,118 +60,7 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur } @Override - public boolean checkRecipeGeneric( - ItemStack[] aItemInputs, - FluidStack[] aFluidInputs, - int aMaxParallelRecipes, - long aEUPercent, - int aSpeedBonusPercent, - int aOutputChanceRoll, - GT_Recipe aRecipe) { - - try { - ArrayList<GT_MetaTileEntity_Hatch_Turbine> aEmptyTurbineRotorHatches = getEmptyTurbineAssemblies(); - if (aEmptyTurbineRotorHatches.size() > 0) { - log("Found " + aEmptyTurbineRotorHatches.size() + " Assemblies without Turbine."); - hatch: - for (GT_MetaTileEntity_Hatch_Turbine aHatch : aEmptyTurbineRotorHatches) { - ArrayList<ItemStack> aTurbines = getAllBufferedTurbines(); - for (ItemStack aTurbineItem : aTurbines) { - if (aTurbineItem == null) { - continue; - } - if (aHatch.insertTurbine(aTurbineItem.copy())) { - boolean aDidDeplete = depleteTurbineFromStock(aTurbineItem); - log("Put Turbine into Assembly - " + aDidDeplete); - continue hatch; - } - } - } - } - - if (getEmptyTurbineAssemblies().size() > 0 || !areAllTurbinesTheSame()) { - log("BAD RETURN - 1"); - stopMachine(); - return false; - } - - ArrayList<FluidStack> tFluids = getStoredFluids(); - - if (tFluids.size() > 0) { - if (baseEff == 0 - || optFlow == 0 - || counter >= 512 - || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled() - || this.getBaseMetaTileEntity().hasInventoryBeenModified()) { - counter = 0; - float aTotalBaseEff = 0; - float aTotalOptimalFlow = 0; - ItemStack aStack = getFullTurbineAssemblies().get(0).getTurbine(); - for (int i = 0; i < getSpeedMultiplier(); i++) { - if (i == 0) { - aTotalBaseEff += GT_Utility.safeInt((long) - ((5F + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack)) - * 1000F)); - } - aTotalOptimalFlow += GT_Utility.safeInt((long) Math.max( - Float.MIN_NORMAL, - ((GT_MetaGenerated_Tool) aStack.getItem()) - .getToolStats(aStack) - .getSpeedMultiplier() - * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed - * 50)); - } - - baseEff = MathUtils.roundToClosestInt(aTotalBaseEff); - optFlow = MathUtils.roundToClosestInt(aTotalOptimalFlow); - if (optFlow <= 0 || baseEff <= 0) { - log("Running checkRecipeGeneric(bad-1)"); - stopMachine(); // in case the turbine got removed - return false; - } - } else { - counter++; - } - } - - // How much the turbine should be producing with this flow - int newPower = fluidIntoPower(tFluids, optFlow, baseEff); - int difference = newPower - this.mEUt; // difference between current output and new output - - // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the - // difference in power level (per tick) - // This is how much the turbine can actually change during this tick - int maxChangeAllowed = Math.max(200, GT_Utility.safeInt((long) Math.abs(difference) / 5)); - - if (Math.abs(difference) - > maxChangeAllowed) { // If this difference is too big, use the maximum allowed change - int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative. - this.mEUt += change; // Apply the change - } else { - this.mEUt = newPower; - } - if (this.mEUt <= 0) { - this.mEUt = 0; - this.mEfficiency = 0; - log("Running checkRecipeGeneric(bad-2)"); - return false; - } else { - this.mMaxProgresstime = 20; - this.mEfficiencyIncrease = 200; - // Overvoltage is handled inside the MultiBlockBase when pushing out to dynamos. no need to do it here. - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - // log("GOOD RETURN - Making: "+this.mEUt+" EU/t"); - return true; - } - } catch (Throwable t) { - t.printStackTrace(); - } - return false; - } - - @Override - int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff) { + int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { if (aFluids.size() >= 1) { aOptFlow *= 800; // CHANGED THINGS HERE, check recipe runs once per 20 ticks int tEU = 0; @@ -185,7 +71,8 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur aFluids.get(0), 0); // Identify a SINGLE type of fluid to process. Doesn't matter which one. Ignore the rest! int fuelValue = getFuelValue(firstFuelType); - actualOptimalFlow = GT_Utility.safeInt((long) Math.ceil((double) aOptFlow / (double) fuelValue)); + actualOptimalFlow = GT_Utility.safeInt( + (long) Math.ceil((double) aOptFlow * (double) flowMultipliers[2] / (double) fuelValue)); this.realOptFlow = actualOptimalFlow; // For scanner info int remainingFlow = GT_Utility.safeInt((long) (actualOptimalFlow diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java index 248359a80b..f2de4a2e81 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java @@ -61,7 +61,7 @@ public class GT_MTE_LargeTurbine_SHSteam extends GregtechMetaTileEntity_LargerTu } @Override - int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff) { + int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { if (looseFit) { aOptFlow *= 4; if (aBaseEff > 10000) { @@ -80,7 +80,7 @@ public class GT_MTE_LargeTurbine_SHSteam extends GregtechMetaTileEntity_LargerTu int remainingFlow = MathUtils.safeInt((long) (aOptFlow * 1.25f)); // Allowed to use up to 125% of optimal flow. Variable required outside of loop for // multi-hatch scenarios. - this.realOptFlow = aOptFlow; + this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0]; storedFluid = 0; for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java index e15f0f3181..7ceda9c9eb 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java @@ -69,7 +69,7 @@ public class GT_MTE_LargeTurbine_Steam extends GregtechMetaTileEntity_LargerTurb } @Override - int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff) { + int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { if (looseFit) { aOptFlow *= 4; if (aBaseEff > 10000) { @@ -88,7 +88,7 @@ public class GT_MTE_LargeTurbine_Steam extends GregtechMetaTileEntity_LargerTurb int remainingFlow = MathUtils.safeInt((long) (aOptFlow * 1.25f)); // Allowed to use up to 125% of optimal flow. Variable required outside of loop for // multi-hatch scenarios. - this.realOptFlow = aOptFlow; + this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0]; storedFluid = 0; for (int i = 0; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java index f187b2420b..b729c5235b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java @@ -50,12 +50,13 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase implements ISurvivalConstructable { protected int baseEff = 0; - protected int optFlow = 0; + protected long optFlow = 0; protected double realOptFlow = 0; protected int storedFluid = 0; protected int counter = 0; protected boolean mFastMode = false; protected double mufflerReduction = 1; + protected float[] flowMultipliers = new float[] {1, 1, 1}; public ITexture frontFace; public ITexture frontFaceActive; @@ -475,9 +476,16 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase .getSpeedMultiplier() * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed * 50)); + if (aTotalOptimalFlow < 0) { + log("Int overflow, report to issue tracker"); + aTotalOptimalFlow = 100; + } // log("Bumped base optimal flow to "+aTotalOptimalFlow); } + flowMultipliers[0] = GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mSteamMultiplier; + flowMultipliers[1] = GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mGasMultiplier; + flowMultipliers[2] = GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mPlasmaMultiplier; // log("Running checkRecipeGeneric(2)"); // log("Total base eff: "+aTotalBaseEff); // log("Total base optimal flow: "+aTotalOptimalFlow); @@ -499,7 +507,7 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase // log("Total optimal flow: "+optFlow); // How much the turbine should be producing with this flow - int newPower = fluidIntoPower(tFluids, optFlow, baseEff); + int newPower = fluidIntoPower(tFluids, optFlow, baseEff, flowMultipliers); // log("Bumped newPower to "+newPower); // log("New Power: "+newPower); int difference = newPower - this.mEUt; // difference between current output and new output @@ -589,7 +597,7 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase return (getFullTurbineAssemblies().size()); } - abstract int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff); + abstract int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers); @Override public int getDamageToComponent(ItemStack aStack) { @@ -665,7 +673,7 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase + Long.toString(storedEnergy) + EnumChatFormatting.RESET + " EU / " + EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET + " EU", StatCollector.translateToLocal("GT5U.turbine.flow") + ": " + EnumChatFormatting.YELLOW - + MathUtils.safeInt((long) realOptFlow) + EnumChatFormatting.RESET + " L/t" + + MathUtils.safeInt((long) realOptFlow) + EnumChatFormatting.RESET + " L/s" + EnumChatFormatting.YELLOW + " (" + (isLooseMode() ? StatCollector.translateToLocal("GT5U.turbine.loose") |