diff options
author | Sampsa <69092953+S4mpsa@users.noreply.github.com> | 2024-09-09 19:25:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-09 18:25:33 +0200 |
commit | 4058d5abf8f70468af8acb50758da927b2aedf82 (patch) | |
tree | 610bcff537bf618c27fe91982472f0d1bf56d93f /src/main/java/gregtech/common | |
parent | abba7f744b7e215a5de73b15c2234caaf97ec91e (diff) | |
download | GT5-Unofficial-4058d5abf8f70468af8acb50758da927b2aedf82.tar.gz GT5-Unofficial-4058d5abf8f70468af8acb50758da927b2aedf82.tar.bz2 GT5-Unofficial-4058d5abf8f70468af8acb50758da927b2aedf82.zip |
Large Large & Larger Turbine Rework (#3075)
Co-authored-by: Daniel Mendes <steelux7@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: NotAPenguin <michiel.vandeginste@gmail.com>
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/java/gregtech/common')
6 files changed, 86 insertions, 208 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbine.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbine.java index 15dc5def03..1a055077ba 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbine.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; @@ -51,6 +52,7 @@ import gregtech.api.recipe.check.CheckRecipeResult; import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GTUtility; import gregtech.api.util.LightingHelper; +import gregtech.api.util.TurbineStatCalculator; import gregtech.api.util.shutdown.ShutDownReasonRegistry; import gregtech.common.items.MetaGeneratedTool01; import gregtech.common.render.GTRenderUtil; @@ -265,6 +267,11 @@ public abstract class MTELargeTurbine extends MTEEnhancedMultiBlockBase<MTELarge stopMachine(ShutDownReasonRegistry.NO_TURBINE); return CheckRecipeResultRegistry.NO_TURBINE_FOUND; } + + TurbineStatCalculator turbine = new TurbineStatCalculator( + (MetaGeneratedTool) controllerSlot.getItem(), + controllerSlot); + ArrayList<FluidStack> tFluids = getStoredFluids(); if (!tFluids.isEmpty()) { @@ -275,21 +282,10 @@ public abstract class MTELargeTurbine extends MTEEnhancedMultiBlockBase<MTELarge || this.getBaseMetaTileEntity() .hasInventoryBeenModified()) { counter = 0; - baseEff = GTUtility.safeInt( - (long) ((5F + ((MetaGeneratedTool) controllerSlot.getItem()).getToolCombatDamage(controllerSlot)) - * 1000F)); - optFlow = GTUtility.safeInt( - (long) Math.max( - Float.MIN_NORMAL, - ((MetaGeneratedTool) controllerSlot.getItem()).getToolStats(controllerSlot) - .getSpeedMultiplier() * MetaGeneratedTool.getPrimaryMaterial(controllerSlot).mToolSpeed - * 50)); - - overflowMultiplier = getOverflowMultiplier(controllerSlot); - - flowMultipliers[0] = MetaGeneratedTool.getPrimaryMaterial(controllerSlot).mSteamMultiplier; - flowMultipliers[1] = MetaGeneratedTool.getPrimaryMaterial(controllerSlot).mGasMultiplier; - flowMultipliers[2] = MetaGeneratedTool.getPrimaryMaterial(controllerSlot).mPlasmaMultiplier; + baseEff = (int) turbine.getEfficiency(); + optFlow = (int) turbine.getOptimalFlow(); + + overflowMultiplier = turbine.getOverflowEfficiency(); if (optFlow <= 0 || baseEff <= 0) { stopMachine(ShutDownReasonRegistry.NONE); // in case the turbine got removed @@ -300,10 +296,10 @@ public abstract class MTELargeTurbine extends MTEEnhancedMultiBlockBase<MTELarge } } - int newPower = fluidIntoPower(tFluids, optFlow, baseEff, overflowMultiplier, flowMultipliers); // How much the - // turbine should - // be producing - // with this flow + int newPower = fluidIntoPower(tFluids, turbine); // How much the + // turbine should + // be producing + // with this flow 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 @@ -329,8 +325,7 @@ public abstract class MTELargeTurbine extends MTEEnhancedMultiBlockBase<MTELarge } } - abstract int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff, int overflowMultiplier, - float[] flowMultipliers); + abstract int fluidIntoPower(ArrayList<FluidStack> aFluids, TurbineStatCalculator turbine); abstract float getOverflowEfficiency(int totalFlow, int actualOptimalFlow, int overflowMultiplier); @@ -344,19 +339,6 @@ public abstract class MTELargeTurbine extends MTEEnhancedMultiBlockBase<MTELarge return aTotal; } - public int getOverflowMultiplier(ItemStack aStack) { - int aOverflowMultiplier = 0; - int toolQualityLevel = MetaGeneratedTool.getPrimaryMaterial(aStack).mToolQuality; - if (toolQualityLevel >= 6) { - aOverflowMultiplier = 3; - } else if (toolQualityLevel >= 3) { - aOverflowMultiplier = 2; - } else { - aOverflowMultiplier = 1; - } - return aOverflowMultiplier; - } - @Override public int getDamageToComponent(ItemStack aStack) { return 1; @@ -472,6 +454,16 @@ public abstract class MTELargeTurbine extends MTEEnhancedMultiBlockBase<MTELarge : this.getMaxEfficiency(mInventory[1]) > 0; } + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (side == getBaseMetaTileEntity().getFrontFacing()) { + looseFit ^= true; + GTUtility.sendChatToPlayer( + aPlayer, + looseFit ? GTUtility.trans("500", "Fitting: Loose - More Flow") + : GTUtility.trans("501", "Fitting: Tight - More Efficiency")); + } + } + @Override public boolean isGivingInformation() { return true; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbineGas.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbineGas.java index 268bbf5da4..ff78aec1f1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbineGas.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbineGas.java @@ -24,6 +24,7 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.TurbineStatCalculator; public class MTELargeTurbineGas extends MTELargeTurbine { @@ -57,6 +58,8 @@ public class MTELargeTurbineGas extends MTELargeTurbine { tt.addMachineType("Gas Turbine") .addInfo("Controller block for the Large Gas Turbine") .addInfo("Needs a Turbine, place inside controller") + .addInfo("Warning: Will be capped at 8192 EU/t in a future update") + .addInfo("See the Advanced Large Gas Turbine as the next, uncapped, option") // .addInfo("The excess fuel that gets consumed will be voided!") .addPollutionAmount(getPollutionPerSecond(null)) .addSeparator() @@ -126,8 +129,7 @@ public class MTELargeTurbineGas extends MTELargeTurbine { } @Override - int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff, int overflowMultiplier, - float[] flowMultipliers) { + int fluidIntoPower(ArrayList<FluidStack> aFluids, TurbineStatCalculator turbine) { if (aFluids.size() >= 1) { int tEU = 0; int actualOptimalFlow = 0; @@ -136,17 +138,18 @@ public class MTELargeTurbineGas extends MTELargeTurbine { // Doesn't matter which one. Ignore the rest! int fuelValue = getFuelValue(firstFuelType); - if (aOptFlow < fuelValue) { + if (turbine.getOptimalGasEUt() < fuelValue) { // turbine too weak and/or fuel too powerful // at least consume 1L this.realOptFlow = 1; // wastes the extra fuel and generate aOptFlow directly depleteInput(new FluidStack(firstFuelType, 1)); this.storedFluid += 1; - return GTUtility.safeInt((long) aOptFlow * (long) aBaseEff / 10000L); + return GTUtility.safeInt((long) turbine.getOptimalGasEUt()); } - actualOptimalFlow = GTUtility.safeInt((long) (aOptFlow * flowMultipliers[1] / fuelValue)); + actualOptimalFlow = GTUtility.safeInt( + (long) ((looseFit ? turbine.getOptimalLooseGasFlow() : turbine.getOptimalGasFlow()) / fuelValue)); this.realOptFlow = actualOptimalFlow; // Allowed to use up to 450% optimal flow rate, depending on the value of overflowMultiplier. @@ -158,7 +161,8 @@ public class MTELargeTurbineGas extends MTELargeTurbine { // - 300% if it is 2 // - 450% if it is 3 // Variable required outside of loop for multi-hatch scenarios. - int remainingFlow = GTUtility.safeInt((long) (actualOptimalFlow * (1.5f * overflowMultiplier))); + int remainingFlow = GTUtility + .safeInt((long) (actualOptimalFlow * (1.5f * turbine.getOverflowEfficiency()))); int flow = 0; int totalFlow = 0; @@ -176,10 +180,11 @@ public class MTELargeTurbineGas extends MTELargeTurbine { tEU = GTUtility.safeInt((long) totalFlow * fuelValue); if (totalFlow != actualOptimalFlow) { - float efficiency = getOverflowEfficiency(totalFlow, actualOptimalFlow, overflowMultiplier); + float efficiency = getOverflowEfficiency(totalFlow, actualOptimalFlow, turbine.getOverflowEfficiency()); tEU *= efficiency; } - tEU = GTUtility.safeInt((long) tEU * (long) aBaseEff / 10000L); + tEU = GTUtility + .safeInt((long) (tEU * (looseFit ? turbine.getLooseGasEfficiency() : turbine.getGasEfficiency()))); // EU/t output cap to properly tier the LGT against the Advanced LGT, will be implemented in a future dev // update diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbineGasAdvanced.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbineGasAdvanced.java index 5b983ddc1b..c1893f50c1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbineGasAdvanced.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbineGasAdvanced.java @@ -24,6 +24,7 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.TurbineStatCalculator; public class MTELargeTurbineGasAdvanced extends MTELargeTurbine { @@ -127,8 +128,7 @@ public class MTELargeTurbineGasAdvanced extends MTELargeTurbine { } @Override - int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff, int overflowMultiplier, - float[] flowMultipliers) { + int fluidIntoPower(ArrayList<FluidStack> aFluids, TurbineStatCalculator turbine) { if (aFluids.size() >= 1) { int tEU = 0; int actualOptimalFlow = 0; @@ -141,17 +141,17 @@ public class MTELargeTurbineGasAdvanced extends MTELargeTurbine { return 0; } - if (aOptFlow < fuelValue) { + if (turbine.getOptimalGasEUt() < fuelValue) { // turbine too weak and/or fuel too powerful // at least consume 1L this.realOptFlow = 1; // wastes the extra fuel and generate aOptFlow directly depleteInput(new FluidStack(firstFuelType, 1)); this.storedFluid += 1; - return GTUtility.safeInt((long) aOptFlow * (long) aBaseEff / 10000L); + return GTUtility.safeInt((long) turbine.getOptimalGasEUt()); } - actualOptimalFlow = GTUtility.safeInt((long) (aOptFlow * flowMultipliers[1] / fuelValue)); + actualOptimalFlow = GTUtility.safeInt((long) (turbine.getOptimalGasFlow() / fuelValue)); this.realOptFlow = actualOptimalFlow; // Allowed to use up to 450% optimal flow rate, depending on the value of overflowMultiplier. @@ -163,7 +163,8 @@ public class MTELargeTurbineGasAdvanced extends MTELargeTurbine { // - 300% if it is 2 // - 450% if it is 3 // Variable required outside of loop for multi-hatch scenarios. - int remainingFlow = GTUtility.safeInt((long) (actualOptimalFlow * (1.5f * overflowMultiplier))); + int remainingFlow = GTUtility + .safeInt((long) (actualOptimalFlow * (1.5f * turbine.getOverflowEfficiency()))); int flow = 0; int totalFlow = 0; @@ -181,10 +182,10 @@ public class MTELargeTurbineGasAdvanced extends MTELargeTurbine { tEU = GTUtility.safeInt((long) totalFlow * fuelValue); if (totalFlow != actualOptimalFlow) { - float efficiency = getOverflowEfficiency(totalFlow, actualOptimalFlow, overflowMultiplier); + float efficiency = getOverflowEfficiency(totalFlow, actualOptimalFlow, turbine.getOverflowEfficiency()); tEU *= efficiency; } - tEU = GTUtility.safeInt((long) tEU * (long) aBaseEff / 10000L); + tEU = GTUtility.safeInt((long) (tEU * turbine.getGasEfficiency())); // If next output is above the maximum the dynamo can handle, set it to the maximum instead of exploding the // turbine diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbineHPSteam.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbineHPSteam.java index e0f3669d39..83fd86742e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbineHPSteam.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbineHPSteam.java @@ -6,12 +6,10 @@ import static gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_NEW_EMPTY5; import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; import static gregtech.api.objects.XSTR.XSTR_INSTANCE; -import static gregtech.common.tileentities.machines.multi.MTELargeTurbineSteam.calculateLooseFlow; import java.util.ArrayList; import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; @@ -26,6 +24,7 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GTModHandler; import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.TurbineStatCalculator; public class MTELargeTurbineHPSteam extends MTELargeTurbine { @@ -103,13 +102,7 @@ public class MTELargeTurbineHPSteam extends MTELargeTurbine { } @Override - int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff, int overflowEfficiency, - float[] flowMultipliers) { - if (looseFit) { - float[] calculatedFlow = calculateLooseFlow(aOptFlow, aBaseEff); - aOptFlow = GTUtility.safeInt((long) calculatedFlow[0]); - aBaseEff = GTUtility.safeInt((long) calculatedFlow[1]); - } + int fluidIntoPower(ArrayList<FluidStack> aFluids, TurbineStatCalculator turbine) { int tEU = 0; int totalFlow = 0; // Byproducts are based on actual flow int flow = 0; @@ -123,8 +116,8 @@ public class MTELargeTurbineHPSteam extends MTELargeTurbine { // - 250% if it is 2 // - 300% if it is 3 // Variable required outside of loop for multi-hatch scenarios. - this.realOptFlow = aOptFlow * flowMultipliers[0]; - int remainingFlow = GTUtility.safeInt((long) (realOptFlow * (0.5f * overflowMultiplier + 1.5))); + this.realOptFlow = looseFit ? turbine.getOptimalLooseSteamFlow() : turbine.getOptimalSteamFlow(); + int remainingFlow = GTUtility.safeInt((long) (realOptFlow * (0.5f * turbine.getOverflowEfficiency() + 1.5))); storedFluid = 0; for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { @@ -155,14 +148,18 @@ public class MTELargeTurbineHPSteam extends MTELargeTurbine { tEU = totalFlow; addOutput(GTModHandler.getSteam(totalFlow)); if (totalFlow == (GTUtility.safeInt((long) realOptFlow))) { - tEU = GTUtility.safeInt((long) tEU * (long) aBaseEff / 10000L); + tEU = GTUtility + .safeInt((long) (tEU * (looseFit ? turbine.getLooseSteamEfficiency() : turbine.getSteamEfficiency()))); } else { float efficiency = getOverflowEfficiency( totalFlow, (GTUtility.safeInt((long) realOptFlow)), overflowMultiplier); tEU *= efficiency; - tEU = Math.max(1, GTUtility.safeInt((long) tEU * (long) aBaseEff / 10000L)); + tEU = Math.max( + 1, + GTUtility.safeInt( + (long) (tEU * (looseFit ? turbine.getLooseSteamEfficiency() : turbine.getSteamEfficiency())))); } // If next output is above the maximum the dynamo can handle, set it to the maximum instead of exploding the @@ -197,17 +194,6 @@ public class MTELargeTurbineHPSteam extends MTELargeTurbine { } @Override - public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (side == getBaseMetaTileEntity().getFrontFacing()) { - looseFit ^= true; - GTUtility.sendChatToPlayer( - aPlayer, - looseFit ? GTUtility.trans("500", "Fitting: Loose - More Flow") - : GTUtility.trans("501", "Fitting: Tight - More Efficiency")); - } - } - - @Override public int getDamageToComponent(ItemStack aStack) { return (looseFit && XSTR_INSTANCE.nextInt(4) == 0) ? 0 : 1; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbinePlasma.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbinePlasma.java index 667d52a4cd..96e0baf985 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbinePlasma.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbinePlasma.java @@ -10,7 +10,6 @@ import static gregtech.api.util.GTUtility.filterValidMTEs; import java.util.ArrayList; import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; @@ -34,7 +33,7 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; -import gregtech.api.util.shutdown.ShutDownReasonRegistry; +import gregtech.api.util.TurbineStatCalculator; import gregtech.common.items.MetaGeneratedTool01; public class MTELargeTurbinePlasma extends MTELargeTurbine { @@ -131,19 +130,19 @@ public class MTELargeTurbinePlasma extends MTELargeTurbine { } @Override - int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff, int overflowMultiplier, - float[] flowMultipliers) { + int fluidIntoPower(ArrayList<FluidStack> aFluids, TurbineStatCalculator turbine) { if (aFluids.size() >= 1) { - aOptFlow *= 800; // CHANGED THINGS HERE, check recipe runs once per 20 ticks int tEU = 0; int actualOptimalFlow = 0; FluidStack firstFuelType = new FluidStack(aFluids.get(0), 0); // Identify a SINGLE type of fluid to process. - // Doesn't matter which one. Ignore the rest! + // Doesn't matter which one. Ignore the rest! int fuelValue = getFuelValue(firstFuelType); - actualOptimalFlow = GTUtility - .safeInt((long) Math.ceil((double) aOptFlow * flowMultipliers[2] / (double) fuelValue)); + actualOptimalFlow = GTUtility.safeInt( + (long) Math.ceil( + (double) (looseFit ? turbine.getOptimalLoosePlasmaFlow() : turbine.getOptimalPlasmaFlow()) * 20 + / (double) fuelValue)); this.realOptFlow = actualOptimalFlow; // For scanner info // Allowed to use up to 550% optimal flow rate, depending on the value of overflowMultiplier. @@ -155,7 +154,8 @@ public class MTELargeTurbinePlasma extends MTELargeTurbine { // - 400% if it is 2 // - 550% if it is 3 // Variable required outside of loop for multi-hatch scenarios. - int remainingFlow = GTUtility.safeInt((long) (actualOptimalFlow * (1.5f * overflowMultiplier + 1))); + int remainingFlow = GTUtility + .safeInt((long) (actualOptimalFlow * (1.5f * turbine.getOverflowEfficiency() + 1))); int flow = 0; int totalFlow = 0; @@ -187,10 +187,11 @@ public class MTELargeTurbinePlasma extends MTELargeTurbine { // GT_FML_LOGGER.info(totalFlow+" : "+fuelValue+" : "+aOptFlow+" : "+actualOptimalFlow+" : "+tEU); if (totalFlow != actualOptimalFlow) { - float efficiency = getOverflowEfficiency(totalFlow, actualOptimalFlow, overflowMultiplier); + float efficiency = getOverflowEfficiency(totalFlow, actualOptimalFlow, turbine.getOverflowEfficiency()); tEU = (int) (tEU * efficiency); } - tEU = GTUtility.safeInt((long) (aBaseEff / 10000D * tEU)); + tEU = GTUtility.safeInt( + (long) ((looseFit ? turbine.getLoosePlasmaEfficiency() : turbine.getPlasmaEfficiency()) * tEU)); // If next output is above the maximum the dynamo can handle, set it to the maximum instead of exploding the // turbine @@ -227,74 +228,14 @@ public class MTELargeTurbinePlasma extends MTELargeTurbine { @Override @NotNull public CheckRecipeResult checkProcessing() { - ItemStack controllerSlot = getControllerSlot(); - if ((counter & 7) == 0 && (controllerSlot == null || !(controllerSlot.getItem() instanceof MetaGeneratedTool) - || controllerSlot.getItemDamage() < 170 - || controllerSlot.getItemDamage() > 179)) { - stopMachine(ShutDownReasonRegistry.NO_TURBINE); - return CheckRecipeResultRegistry.NO_TURBINE_FOUND; - } - ArrayList<FluidStack> tFluids = getStoredFluids(); - if (!tFluids.isEmpty()) { - if (baseEff == 0 || optFlow == 0 - || counter >= 512 - || this.getBaseMetaTileEntity() - .hasWorkJustBeenEnabled() - || this.getBaseMetaTileEntity() - .hasInventoryBeenModified()) { - counter = 0; - baseEff = GTUtility.safeInt( - (long) ((5F + ((MetaGeneratedTool) controllerSlot.getItem()).getToolCombatDamage(controllerSlot)) - * 1000F)); - optFlow = GTUtility.safeInt( - (long) Math.max( - Float.MIN_NORMAL, - ((MetaGeneratedTool) controllerSlot.getItem()).getToolStats(controllerSlot) - .getSpeedMultiplier() * MetaGeneratedTool.getPrimaryMaterial(controllerSlot).mToolSpeed - * 50)); - overflowMultiplier = getOverflowMultiplier(controllerSlot); - - flowMultipliers[0] = MetaGeneratedTool.getPrimaryMaterial(controllerSlot).mSteamMultiplier; - flowMultipliers[1] = MetaGeneratedTool.getPrimaryMaterial(controllerSlot).mGasMultiplier; - flowMultipliers[2] = MetaGeneratedTool.getPrimaryMaterial(controllerSlot).mPlasmaMultiplier; - - if (optFlow <= 0 || baseEff <= 0) { - stopMachine(ShutDownReasonRegistry.NONE); // in case the turbine got removed - return CheckRecipeResultRegistry.NO_FUEL_FOUND; - } - } else { - counter++; - } - } - - int newPower = fluidIntoPower(tFluids, optFlow, baseEff, overflowMultiplier, flowMultipliers); // How much the - // turbine should - // be producing - // with this flow - - 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, GTUtility.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) { - // stopMachine(); - this.mEUt = 0; - this.mEfficiency = 0; - return CheckRecipeResultRegistry.NO_FUEL_FOUND; - } else { + CheckRecipeResult status = super.checkProcessing(); + if (status == CheckRecipeResultRegistry.GENERATING) { + // The plasma turbine runs only once every 20 ticks this.mMaxProgresstime = 20; this.mEfficiencyIncrease = 200; - // Overvoltage is handled inside the MultiBlockBase when pushing out to dynamos. no need to do it here. - return CheckRecipeResultRegistry.GENERATING; + } else { + return status; } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbineSteam.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbineSteam.java index b017862fa8..8c6f00d52f 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbineSteam.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbineSteam.java @@ -11,7 +11,6 @@ import static gregtech.api.objects.XSTR.XSTR_INSTANCE; import java.util.ArrayList; import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; @@ -26,12 +25,12 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GTModHandler; import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.TurbineStatCalculator; public class MTELargeTurbineSteam extends MTELargeTurbine { private int excessWater; private boolean achievement = false; - private boolean looseFit = false; public MTELargeTurbineSteam(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -111,13 +110,7 @@ public class MTELargeTurbineSteam extends MTELargeTurbine { } @Override - int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff, int overflowEfficiency, - float[] flowMultipliers) { - if (looseFit) { - float[] calculatedFlow = calculateLooseFlow(aOptFlow, aBaseEff); - aOptFlow = GTUtility.safeInt((long) calculatedFlow[0]); - aBaseEff = GTUtility.safeInt((long) calculatedFlow[1]); - } + int fluidIntoPower(ArrayList<FluidStack> aFluids, TurbineStatCalculator turbine) { int tEU = 0; int totalFlow = 0; // Byproducts are based on actual flow int flow = 0; @@ -131,8 +124,8 @@ public class MTELargeTurbineSteam extends MTELargeTurbine { // - 200% if it is 2 // - 250% if it is 3 // Variable required outside of loop for multi-hatch scenarios. - this.realOptFlow = aOptFlow * flowMultipliers[0]; - int remainingFlow = GTUtility.safeInt((long) (realOptFlow * (0.5f * overflowMultiplier + 1))); + this.realOptFlow = looseFit ? turbine.getOptimalLooseSteamFlow() : turbine.getOptimalSteamFlow(); + int remainingFlow = GTUtility.safeInt((long) (realOptFlow * (0.5f * turbine.getOverflowEfficiency() + 1))); storedFluid = 0; for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { // loop through each hatch; extract inputs and @@ -163,14 +156,19 @@ public class MTELargeTurbineSteam extends MTELargeTurbine { int waterToOutput = condenseSteam(totalFlow); addOutput(GTModHandler.getDistilledWater(waterToOutput)); if (totalFlow == (GTUtility.safeInt((long) realOptFlow))) { - tEU = GTUtility.safeInt((long) tEU * (long) aBaseEff / 20000L); + tEU = GTUtility.safeInt( + (long) (tEU * (looseFit ? turbine.getLooseSteamEfficiency() : turbine.getSteamEfficiency()) * 0.5f)); } else { float efficiency = getOverflowEfficiency( totalFlow, (GTUtility.safeInt((long) realOptFlow)), overflowMultiplier); tEU *= efficiency; - tEU = Math.max(1, GTUtility.safeInt((long) tEU * (long) aBaseEff / 20000L)); + tEU = Math.max( + 1, + GTUtility.safeInt( + (long) (tEU * (looseFit ? turbine.getLooseSteamEfficiency() : turbine.getSteamEfficiency()) + * 0.5f))); } // If next output is above the maximum the dynamo can handle, set it to the maximum instead of exploding the @@ -203,51 +201,6 @@ public class MTELargeTurbineSteam extends MTELargeTurbine { return efficiency; } - public static float[] calculateLooseFlow(float aOptFlow, float aBaseEff) { - aOptFlow *= 4f; - if (aBaseEff >= 26000f) { - aOptFlow = aOptFlow * (float) Math.pow(1.1f, ((aBaseEff - 8000f) / 10000f) * 20f); - aBaseEff = aBaseEff * 0.6f; - } else if (aBaseEff > 22000f) { - aOptFlow = aOptFlow * (float) Math.pow(1.1f, ((aBaseEff - 7000f) / 10000f) * 20f); - aBaseEff = aBaseEff * 0.65f; - } else if (aBaseEff > 18000f) { - aOptFlow = aOptFlow * (float) Math.pow(1.1f, ((aBaseEff - 6000f) / 10000f) * 20f); - aBaseEff = aBaseEff * 0.70f; - } else if (aBaseEff > 14000f) { - aOptFlow = aOptFlow * (float) Math.pow(1.1f, ((aBaseEff - 5000f) / 10000f) * 20f); - aBaseEff = aBaseEff * 0.75f; - } else if (aBaseEff > 10000f) { - aOptFlow = aOptFlow * (float) Math.pow(1.1f, ((aBaseEff - 4000f) / 10000f) * 20f); - aBaseEff = aBaseEff * 0.8f; - } else if (aBaseEff > 6000f) { - aOptFlow = aOptFlow * (float) Math.pow(1.1f, ((aBaseEff - 3000f) / 10000f) * 20f); - aBaseEff = aBaseEff * 0.85f; - } else { - aBaseEff = aBaseEff * 0.9f; - } - - if (aBaseEff % 100 != 0) { - aBaseEff -= aBaseEff % 100; - } - - float[] looseFlow = new float[2]; - looseFlow[0] = aOptFlow; - looseFlow[1] = aBaseEff; - return looseFlow; - } - - @Override - public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (side == getBaseMetaTileEntity().getFrontFacing()) { - looseFit ^= true; - GTUtility.sendChatToPlayer( - aPlayer, - looseFit ? GTUtility.trans("500", "Fitting: Loose - More Flow") - : GTUtility.trans("501", "Fitting: Tight - More Efficiency")); - } - } - @Override public int getDamageToComponent(ItemStack aStack) { return (looseFit && XSTR_INSTANCE.nextInt(4) == 0) ? 0 : 1; |