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 | |
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')
21 files changed, 674 insertions, 651 deletions
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/MTEExtremeHeatExchanger.java b/src/main/java/goodgenerator/blocks/tileEntity/MTEExtremeHeatExchanger.java index c37a2026d4..582b9d04aa 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/MTEExtremeHeatExchanger.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/MTEExtremeHeatExchanger.java @@ -210,10 +210,10 @@ public class MTEExtremeHeatExchanger extends MTETooltipMultiBlockBaseEM .addInfo(BLUE_PRINT_INFO) .addSeparator() .addController("Front bottom") - .addOtherStructurePart("Input Hatch", "Distilled water. Any bottom left/right side casing", 1) - .addOtherStructurePart("Output Hatch", "SC Steam/SH Steam/Steam. Any top layer casing", 2) - .addOtherStructurePart("Input Hatch", "Hot fluid or plasma. Front middle on 4th layer", 3) - .addOtherStructurePart("Output Hatch", "Cold fluid. Back middle on 4th layer", 4) + .addOtherStructurePart("Input Hatch", "distilled water", 1) + .addOtherStructurePart("Output Hatch", "SC Steam/SH Steam/Steam", 2) + .addOtherStructurePart("Input Hatch", "Hot fluid or plasma", 3) + .addOtherStructurePart("Output Hatch", "Cold fluid", 4) .addMaintenanceHatch("Any Casing", 1, 2, 5) .addCasingInfoMin("Robust Tungstensteel Machine Casings", 25, false) .toolTipFinisher("Good Generator"); @@ -268,8 +268,15 @@ public class MTEExtremeHeatExchanger extends MTETooltipMultiBlockBaseEM Fluid tReadySteam = transformed ? tRunningRecipe.getHeatedSteam() : tRunningRecipe.getNormalSteam(); int waterAmount = (int) (this.mEUt / getUnitSteamPower(tReadySteam.getName())) / 160; if (waterAmount < 0) return false; + int steamToOutput; if (depleteInput(GTModHandler.getDistilledWater(waterAmount))) { - addOutput(new FluidStack(tReadySteam, waterAmount * 160)); + if (tRunningRecipe.mFluidInputs[0].getUnlocalizedName() + .contains("plasma")) { + steamToOutput = waterAmount * 160 / 1000; + } else { + steamToOutput = waterAmount * 160; + } + addOutput(new FluidStack(tReadySteam, steamToOutput)); } else { GTLog.exp.println(this.mName + " had no more Distilled water!"); mHotFluidHatch.getBaseMetaTileEntity() @@ -281,16 +288,13 @@ public class MTEExtremeHeatExchanger extends MTETooltipMultiBlockBaseEM } public double getUnitSteamPower(String steam) { - switch (steam) { - case "steam": - return 0.5; - case "ic2superheatedsteam": - return 1; - case "supercriticalsteam": - return 100; - default: - return -1; - } + return switch (steam) { + case "steam" -> 0.5; + case "ic2superheatedsteam" -> 1; + case "supercriticalsteam" -> 100; + case "densesupercriticalsteam" -> 1; + default -> -1; + }; } @Override diff --git a/src/main/java/goodgenerator/blocks/tileEntity/MTESupercriticalFluidTurbine.java b/src/main/java/goodgenerator/blocks/tileEntity/MTESupercriticalFluidTurbine.java index a78046909a..e7ea94f3c8 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/MTESupercriticalFluidTurbine.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/MTESupercriticalFluidTurbine.java @@ -24,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 MTESupercriticalFluidTurbine extends MTELargeTurbineBase { @@ -42,27 +43,14 @@ public class MTESupercriticalFluidTurbine extends MTELargeTurbineBase { } @Override - public int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff) { - if (looseFit) { - aOptFlow *= 4; - double pow = Math.pow(1.1f, ((aBaseEff - 7500) / 10000F) * 20f); - if (aBaseEff > 10000) { - aOptFlow *= pow; - aBaseEff = 7500; - } else if (aBaseEff > 7500) { - aOptFlow *= pow; - aBaseEff *= 0.75f; - } else { - aBaseEff *= 0.75f; - } - } + public int fluidIntoPower(ArrayList<FluidStack> aFluids, TurbineStatCalculator turbine) { + int tEU = 0; int totalFlow = 0; // Byproducts are based on actual flow int flow = 0; - int remainingFlow = GTUtility.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 = looseFit ? turbine.getOptimalLooseSteamFlow() : turbine.getOptimalSteamFlow(); + int remainingFlow = GTUtility.safeInt((long) (realOptFlow * 1.25f)); // Allowed to use up to 125% of optimal + // flow. storedFluid = 0; FluidStack tSCSteam = FluidRegistry.getFluidStack("supercriticalsteam", 1); @@ -80,20 +68,24 @@ public class MTESupercriticalFluidTurbine extends MTELargeTurbineBase { } if (totalFlow <= 0) return 0; tEU = totalFlow; - addOutput(GTModHandler.getSteam(totalFlow * 100)); - if (totalFlow == aOptFlow) { - tEU = GTUtility.safeInt((long) tEU * (long) aBaseEff / 10000L); + addOutput(GTModHandler.getSteam(totalFlow)); + if (totalFlow == realOptFlow) { + tEU = GTUtility + .safeInt((long) (tEU * (looseFit ? turbine.getLooseSteamEfficiency() : turbine.getSteamEfficiency()))); } else { - float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float) aOptFlow); + float efficiency = 1.0f - (float) Math.abs((totalFlow - realOptFlow) / (float) realOptFlow); 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 (tEU > maxPower) { tEU = GTUtility.safeInt(maxPower); } - return tEU * 100; + return tEU; } @Override @@ -153,8 +145,7 @@ public class MTESupercriticalFluidTurbine extends MTELargeTurbineBase { .addInfo("Controller block for Supercritical Fluid Turbine") .addInfo("Needs a Turbine, place inside controller") .addInfo("Use Supercritical Steam to generate power.") - .addInfo("Outputs 100L of Steam per 1L of SC Steam as well as producing power") - .addInfo("1L Supercritical Steam = 100 EU") + .addInfo("Outputs 1L of Steam per 1L of SC Steam as well as producing power") .addInfo("Extreme Heated Steam will cause more damage to the turbine.") .addInfo("Power output depends on turbine and fitting") .addInfo("Use screwdriver to adjust fitting of turbine") @@ -165,6 +156,7 @@ public class MTESupercriticalFluidTurbine extends MTELargeTurbineBase { .addDynamoHatch("Back center", 1) .addMaintenanceHatch("Side centered", 2) .addInputHatch("Supercritical Fluid, Side centered", 2) + .addOutputHatch("Superheated Steam, Side centered", 3) .toolTipFinisher("Good Generator"); return tt; } diff --git a/src/main/java/goodgenerator/blocks/tileEntity/base/MTELargeTurbineBase.java b/src/main/java/goodgenerator/blocks/tileEntity/base/MTELargeTurbineBase.java index 1c298d2b9a..086aa28528 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/base/MTELargeTurbineBase.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/base/MTELargeTurbineBase.java @@ -35,6 +35,8 @@ import gregtech.api.metatileentity.implementations.MTEHatchMuffler; import gregtech.api.recipe.check.CheckRecipeResult; import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GTUtility; +import gregtech.api.util.TurbineStatCalculator; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; import gregtech.common.items.MetaGeneratedTool01; public abstract class MTELargeTurbineBase extends MTEEnhancedMultiBlockBase<MTELargeTurbineBase> @@ -79,6 +81,7 @@ public abstract class MTELargeTurbineBase extends MTEEnhancedMultiBlockBase<MTEL protected int storedFluid = 0; protected int counter = 0; protected boolean looseFit = false; + protected int overflowMultiplier = 0; protected long maxPower = 0; public MTELargeTurbineBase(int aID, String aName, String aNameRegional) { @@ -140,11 +143,17 @@ public abstract class MTELargeTurbineBase extends MTEEnhancedMultiBlockBase<MTEL if ((counter & 7) == 0 && (controllerSlot == null || !(controllerSlot.getItem() instanceof MetaGeneratedTool) || controllerSlot.getItemDamage() < 170 || controllerSlot.getItemDamage() > 179)) { - stopMachine(); + stopMachine(ShutDownReasonRegistry.NO_TURBINE); return CheckRecipeResultRegistry.NO_TURBINE_FOUND; } + + TurbineStatCalculator turbine = new TurbineStatCalculator( + (MetaGeneratedTool) controllerSlot.getItem(), + controllerSlot); + ArrayList<FluidStack> tFluids = getStoredFluids(); - if (tFluids.size() > 0) { + if (!tFluids.isEmpty()) { + if (baseEff == 0 || optFlow == 0 || counter >= 512 || this.getBaseMetaTileEntity() @@ -152,17 +161,13 @@ public abstract class MTELargeTurbineBase extends MTEEnhancedMultiBlockBase<MTEL || 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)); + baseEff = (int) turbine.getEfficiency(); + optFlow = (int) turbine.getOptimalFlow(); + + overflowMultiplier = turbine.getOverflowEfficiency(); + if (optFlow <= 0 || baseEff <= 0) { - stopMachine(); // in case the turbine got removed + stopMachine(ShutDownReasonRegistry.NONE); // in case the turbine got removed return CheckRecipeResultRegistry.NO_FUEL_FOUND; } } else { @@ -170,8 +175,8 @@ public abstract class MTELargeTurbineBase extends MTEEnhancedMultiBlockBase<MTEL } } - int newPower = fluidIntoPower(tFluids, optFlow, baseEff); // 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 @@ -197,7 +202,7 @@ public abstract class MTELargeTurbineBase extends MTEEnhancedMultiBlockBase<MTEL } } - public abstract int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff); + public abstract int fluidIntoPower(ArrayList<FluidStack> aFluids, TurbineStatCalculator turbine); @Override public int getDamageToComponent(ItemStack aStack) { diff --git a/src/main/java/goodgenerator/loader/RecipeLoader2.java b/src/main/java/goodgenerator/loader/RecipeLoader2.java index a66b9360d6..1c4c05948d 100644 --- a/src/main/java/goodgenerator/loader/RecipeLoader2.java +++ b/src/main/java/goodgenerator/loader/RecipeLoader2.java @@ -1843,7 +1843,7 @@ public class RecipeLoader2 { .addTo(plasmaForgeRecipes); } - public static float EHEEfficiencyMultiplier = 1.2f; + public static float EHEEfficiencyMultiplier = 0.9f; public static void FinishLoadRecipe() { for (GTRecipe plasmaFuel : RecipeMaps.plasmaFuels.getAllRecipes()) { @@ -1872,13 +1872,13 @@ public class RecipeLoader2 { if (output == null) output = FluidRegistry.getFluidStack("molten." + tOutName, tPlasma.amount); if (output != null) { long waterAmount = (long) (tUnit * EHEEfficiencyMultiplier * tPlasma.amount / 160); - long criticalSteamAmount = (long) (tUnit * EHEEfficiencyMultiplier * tPlasma.amount / 100); + long criticalSteamAmount = (long) (tUnit * EHEEfficiencyMultiplier * tPlasma.amount / 1000); MyRecipeAdder.instance.addExtremeHeatExchangerRecipe( tPlasma, output, FluidRegistry.getFluidStack("ic2distilledwater", (int) waterAmount), FluidRegistry.getFluidStack("ic2superheatedsteam", 0), // Plasma always outputs SC steam. - FluidRegistry.getFluidStack("supercriticalsteam", (int) criticalSteamAmount), + Materials.DenseSupercriticalSteam.getGas(criticalSteamAmount), 1); } } diff --git a/src/main/java/gregtech/api/enums/Materials.java b/src/main/java/gregtech/api/enums/Materials.java index 177dc4f589..5aa02b8094 100644 --- a/src/main/java/gregtech/api/enums/Materials.java +++ b/src/main/java/gregtech/api/enums/Materials.java @@ -948,6 +948,18 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { public static Materials TengamAttuned; public static Materials TengamRaw; + public static Materials DenseSteam = makeDenseSteam(); + private static Materials makeDenseSteam() { + return new MaterialBuilder(232, TextureSet.SET_FLUID , "Dense Steam").addCell().addGas().setRGB(255, 255, 255).setColor(Dyes.dyeWhite).constructMaterial(); + } + public static Materials DenseSuperheatedSteam = makeDenseSuperheatedSteam(); + private static Materials makeDenseSuperheatedSteam() { + return new MaterialBuilder(233, TextureSet.SET_FLUID , "Dense Superheated Steam").addCell().addGas().setRGB(255, 255, 255).setColor(Dyes.dyeWhite).constructMaterial(); + } + public static Materials DenseSupercriticalSteam = makeDenseSupercriticalSteam(); + private static Materials makeDenseSupercriticalSteam() { + return new MaterialBuilder(234, TextureSet.SET_FLUID , "Dense Supercritical Steam").addCell().addGas().setRGB(255, 255, 255).setColor(Dyes.dyeWhite).constructMaterial(); + } // Activated Carbon Line and waterline chemicals public static Materials ActivatedCarbon; public static Materials PreActivatedCarbon; diff --git a/src/main/java/gregtech/api/items/MetaGeneratedTool.java b/src/main/java/gregtech/api/items/MetaGeneratedTool.java index 6487a67a6b..dd3d50b739 100644 --- a/src/main/java/gregtech/api/items/MetaGeneratedTool.java +++ b/src/main/java/gregtech/api/items/MetaGeneratedTool.java @@ -1,7 +1,6 @@ package gregtech.api.items; import static gregtech.api.util.GTUtility.formatNumbers; -import static gregtech.common.tileentities.machines.multi.MTELargeTurbineSteam.calculateLooseFlow; import java.util.ArrayList; import java.util.HashMap; @@ -55,6 +54,7 @@ import gregtech.api.util.GTLanguageManager; import gregtech.api.util.GTModHandler; import gregtech.api.util.GTOreDictUnificator; import gregtech.api.util.GTUtility; +import gregtech.api.util.TurbineStatCalculator; import gregtech.common.tools.ToolTurbine; import mods.railcraft.api.core.items.IToolCrowbar; import mrtjp.projectred.api.IScrewdriver; @@ -428,165 +428,144 @@ public abstract class MetaGeneratedTool extends MetaBaseItem // EU/t -> toolCombatDamage, toolSpeed // Overflow Tier -> toolQuality float aBaseEff = (5f + getToolCombatDamage(aStack)) * 1000f; - + TurbineStatCalculator turbine = new TurbineStatCalculator((MetaGeneratedTool) aStack.getItem(), aStack); // It was noted by IntelliJ that replacing ((GT_MetaGenerated_Tool) aStack.getItem()) with // GT_MetaGenerated_Tool can have side effects. This refactoring will need tests. @SuppressWarnings("AccessStaticViaInstance") - float aOptFlow = (Math.max( - Float.MIN_NORMAL, - ((MetaGeneratedTool) aStack.getItem()).getToolStats(aStack) - .getSpeedMultiplier() - * ((MetaGeneratedTool) aStack.getItem()).getPrimaryMaterial(aStack).mToolSpeed - * 50F)); + float aOptFlow = (Math.max(Float.MIN_NORMAL, turbine.getOptimalFlow())); aList.add( tOffset + 0, EnumChatFormatting.GRAY + String.format( transItem("001", "Durability: %s/%s"), - "" + EnumChatFormatting.GREEN + formatNumbers(tMaxDamage - getToolDamage(aStack)) + " ", - " " + formatNumbers(tMaxDamage)) + EnumChatFormatting.GRAY); + "" + EnumChatFormatting.GREEN + formatNumbers(turbine.getCurrentDurability()) + " ", + " " + formatNumbers(turbine.getMaxDurability())) + EnumChatFormatting.GRAY); aList.add( tOffset + 1, EnumChatFormatting.GRAY + String.format( - transItem("002", "%s lvl %s"), - tMaterial.mLocalizedName + EnumChatFormatting.YELLOW, + transItem("002", "%s Tier %s"), + tMaterial.mLocalizedName + ":" + EnumChatFormatting.YELLOW, "" + getHarvestLevel(aStack, "")) + EnumChatFormatting.GRAY); aList.add( tOffset + 2, EnumChatFormatting.WHITE + String.format( - transItem("005", "Turbine Efficiency: %s"), - "" + EnumChatFormatting.BLUE + (50.0F + (10.0F * getToolCombatDamage(aStack)))) + transItem("005", "Base Efficiency: %s"), + "" + EnumChatFormatting.BLUE + (int) Math.ceil(turbine.getEfficiency() * 100)) + "%" + EnumChatFormatting.GRAY); aList.add( tOffset + 3, - EnumChatFormatting.WHITE + String.format( - transItem("006", "Optimal Steam flow: %s L/t"), - "" + EnumChatFormatting.GOLD - + formatNumbers( - GTUtility.safeInt( - (long) (Math.max( - Float.MIN_NORMAL, - tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed - * (1000 * getPrimaryMaterial(aStack).mSteamMultiplier / 20))))) - + EnumChatFormatting.GRAY)); + EnumChatFormatting.GRAY + transItem("006", "Fuel | Optimal Flow > EU/t Produced | Efficiency")); aList.add( tOffset + 4, - EnumChatFormatting.WHITE + String.format( - transItem("900", "Energy from Optimal Steam Flow: %s EU/t"), - "" + EnumChatFormatting.GOLD - + formatNumbers( - GTUtility.safeInt( - (long) (Math.max( - Float.MIN_NORMAL, - tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed - * (1000 * getPrimaryMaterial(aStack).mSteamMultiplier / 20)) - * (50.0F + (10.0F * getToolCombatDamage(aStack))) - / 200))) - + EnumChatFormatting.GRAY)); - { - float[] calculatedFlow = calculateLooseFlow(aOptFlow, aBaseEff); - float aOptFlowLoose = calculatedFlow[0]; - float aBaseEffLoose = calculatedFlow[1]; - - aList.add( - tOffset + 5, - EnumChatFormatting.AQUA + String.format( - transItem("500", "Turbine Efficiency (Loose): %s"), - "" + EnumChatFormatting.BLUE + (long) aBaseEffLoose / 100 + "%" + EnumChatFormatting.GRAY)); - aList.add( - tOffset + 6, - EnumChatFormatting.AQUA + String.format( - transItem("501", "Optimal Steam flow (Loose): %s L/t"), + EnumChatFormatting.WHITE + " Steam " + + EnumChatFormatting.GRAY + + " | " + + String.format( + "%s L/t > %s EU/t | %s", "" + EnumChatFormatting.GOLD - + formatNumbers(((long) aOptFlowLoose * getPrimaryMaterial(aStack).mSteamMultiplier)) + + formatNumbers(GTUtility.safeInt((long) (turbine.getOptimalSteamFlow()))) + + EnumChatFormatting.GRAY, + "" + EnumChatFormatting.DARK_GREEN + + formatNumbers(GTUtility.safeInt((long) (turbine.getOptimalSteamEUt()))) + + EnumChatFormatting.GRAY, + "" + EnumChatFormatting.BLUE + + (int) (turbine.getSteamEfficiency() * 100) + + "%" + EnumChatFormatting.GRAY)); - aList.add( - tOffset + 7, - EnumChatFormatting.AQUA + String.format( - transItem("901", "Energy from Optimal Steam Flow (Loose): %s EU/t"), + aList.add( + tOffset + 5, + EnumChatFormatting.WHITE + " Loose " + + EnumChatFormatting.GRAY + + " | " + + String.format( + "%s L/t > %s EU/t | %s", "" + EnumChatFormatting.GOLD - + formatNumbers( - ((long) aOptFlowLoose * getPrimaryMaterial(aStack).mSteamMultiplier / 10000) - * ((long) aBaseEffLoose / 2)) + + formatNumbers(GTUtility.safeInt((long) (turbine.getOptimalLooseSteamFlow()))) + + EnumChatFormatting.GRAY, + "" + EnumChatFormatting.DARK_GREEN + + formatNumbers(GTUtility.safeInt((long) (turbine.getOptimalLooseSteamEUt()))) + + EnumChatFormatting.GRAY, + "" + EnumChatFormatting.BLUE + + (int) (turbine.getLooseSteamEfficiency() * 100) + + "%" + EnumChatFormatting.GRAY)); - aList.add( - tOffset + 8, - EnumChatFormatting.GRAY + "(Superheated Steam EU values are 2x those of Steam)"); - } aList.add( - tOffset + 9, - EnumChatFormatting.WHITE + String.format( - transItem("902", "Optimal SC Steam flow: %s L/t"), - "" + EnumChatFormatting.GOLD - + formatNumbers( - GTUtility.safeInt( - (long) (Math.max( - Float.MIN_NORMAL, - tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed - * (1000f / 20f))))) - + EnumChatFormatting.GRAY)); + tOffset + 6, + EnumChatFormatting.DARK_GRAY + " Supercritical and Superheated EU values are 2x"); aList.add( - tOffset + 10, - EnumChatFormatting.WHITE + String.format( - transItem("903", "Energy from Optimal SC Steam Flow: %s EU/t"), - "" + EnumChatFormatting.GOLD - + formatNumbers( - GTUtility.safeInt( - (long) (Math.max( - Float.MIN_NORMAL, - tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed - * (1000f / 20f)) - * (50.0F + (10.0F * getToolCombatDamage(aStack)))))) - + EnumChatFormatting.GRAY)); + tOffset + 7, + EnumChatFormatting.AQUA + " Gas " + + EnumChatFormatting.GRAY + + " | " + + String.format( + "%s EU/t > %s EU/t | %s", + "" + EnumChatFormatting.GOLD + + formatNumbers(GTUtility.safeInt((long) (turbine.getOptimalGasFlow()))) + + EnumChatFormatting.GRAY, + "" + EnumChatFormatting.DARK_GREEN + + formatNumbers(GTUtility.safeInt((long) (turbine.getOptimalGasEUt()))) + + EnumChatFormatting.GRAY, + "" + EnumChatFormatting.BLUE + + (int) (turbine.getGasEfficiency() * 100) + + "%" + + EnumChatFormatting.GRAY)); aList.add( - tOffset + 11, - EnumChatFormatting.LIGHT_PURPLE + String.format( - transItem("007", "Energy from Optimal Gas Flow: %s EU/t"), - "" + EnumChatFormatting.GOLD - + formatNumbers( - GTUtility.safeInt( - (long) (Math.max( - Float.MIN_NORMAL, - tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed - * 50 - * getPrimaryMaterial(aStack).mGasMultiplier) - * (50.0F + (10.0F * getToolCombatDamage(aStack))) - / 100))) - + EnumChatFormatting.GRAY)); + tOffset + 8, + EnumChatFormatting.AQUA + " Loose " + + EnumChatFormatting.GRAY + + " | " + + String.format( + "%s EU/t > %s EU/t | %s", + "" + EnumChatFormatting.GOLD + + formatNumbers(GTUtility.safeInt((long) (turbine.getOptimalLooseGasFlow()))) + + EnumChatFormatting.GRAY, + "" + EnumChatFormatting.DARK_GREEN + + formatNumbers(GTUtility.safeInt((long) (turbine.getOptimalLooseGasEUt()))) + + EnumChatFormatting.GRAY, + "" + EnumChatFormatting.BLUE + + (int) (turbine.getLooseGasEfficiency() * 100) + + "%" + + EnumChatFormatting.GRAY)); aList.add( - tOffset + 12, - EnumChatFormatting.LIGHT_PURPLE + String.format( - transItem("008", "Energy from Optimal Plasma Flow: %s EU/t"), - "" + EnumChatFormatting.GOLD - + formatNumbers( - GTUtility.safeInt( - (long) (Math.max( - Float.MIN_NORMAL, - tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed - * 2000 - * getPrimaryMaterial(aStack).mPlasmaMultiplier) - * (50.0F + (10.0F * getToolCombatDamage(aStack))) - * (1.05 / 100)))) - + EnumChatFormatting.GRAY)); + tOffset + 9, + EnumChatFormatting.LIGHT_PURPLE + " Plasma" + + EnumChatFormatting.GRAY + + " | " + + String.format( + "%s EU/t > %s EU/t | %s", + "" + EnumChatFormatting.GOLD + + formatNumbers(GTUtility.safeInt((long) (turbine.getOptimalPlasmaFlow()))) + + EnumChatFormatting.GRAY, + "" + EnumChatFormatting.DARK_GREEN + + formatNumbers(GTUtility.safeInt((long) (turbine.getOptimalPlasmaEUt()))) + + EnumChatFormatting.GRAY, + "" + EnumChatFormatting.BLUE + + (int) (turbine.getPlasmaEfficiency() * 100) + + "%" + + EnumChatFormatting.GRAY)); aList.add( - tOffset + 14, - EnumChatFormatting.GRAY + "(EU/t values include efficiency and are not 100% accurate)"); - int toolQualityLevel = MetaGeneratedTool.getPrimaryMaterial(aStack).mToolQuality; - int overflowMultiplier = 0; - if (toolQualityLevel >= 6) { - overflowMultiplier = 3; - } else if (toolQualityLevel >= 3) { - overflowMultiplier = 2; - } else { - overflowMultiplier = 1; - } + tOffset + 10, + EnumChatFormatting.LIGHT_PURPLE + " Loose" + + EnumChatFormatting.GRAY + + " | " + + String.format( + "%s EU/t > %s EU/t | %s", + "" + EnumChatFormatting.GOLD + + formatNumbers(GTUtility.safeInt((long) (turbine.getOptimalLoosePlasmaFlow()))) + + EnumChatFormatting.GRAY, + "" + EnumChatFormatting.DARK_GREEN + + formatNumbers(GTUtility.safeInt((long) (turbine.getOptimalLoosePlasmaEUt()))) + + EnumChatFormatting.GRAY, + "" + EnumChatFormatting.BLUE + + (int) (turbine.getLoosePlasmaEfficiency() * 100) + + "%" + + EnumChatFormatting.GRAY)); aList.add( - tOffset + 13, + tOffset + 11, EnumChatFormatting.LIGHT_PURPLE + String.format( transItem("502", "Overflow Efficiency Tier: %s"), - "" + EnumChatFormatting.GOLD + overflowMultiplier + EnumChatFormatting.GRAY)); - + "" + EnumChatFormatting.GOLD + turbine.getOverflowEfficiency() + EnumChatFormatting.GRAY)); } else { aList.add( tOffset, diff --git a/src/main/java/gregtech/api/util/GTLanguageManager.java b/src/main/java/gregtech/api/util/GTLanguageManager.java index 73e503e75a..06ba98fe8d 100644 --- a/src/main/java/gregtech/api/util/GTLanguageManager.java +++ b/src/main/java/gregtech/api/util/GTLanguageManager.java @@ -561,11 +561,11 @@ public class GTLanguageManager { addStringLocalization("Item_DESCRIPTION_Index_000", "Stored Heat: %s"); addStringLocalization("Item_DESCRIPTION_Index_001", "Durability: %s/%s"); - addStringLocalization("Item_DESCRIPTION_Index_002", "%s lvl %s"); + addStringLocalization("Item_DESCRIPTION_Index_002", "%s Tier %s"); addStringLocalization("Item_DESCRIPTION_Index_003", "Attack Damage: %s"); addStringLocalization("Item_DESCRIPTION_Index_004", "Mining Speed: %s"); - addStringLocalization("Item_DESCRIPTION_Index_005", "Turbine Efficiency: %s"); - addStringLocalization("Item_DESCRIPTION_Index_006", "Optimal Steam flow: %s L/t"); + addStringLocalization("Item_DESCRIPTION_Index_005", "Base Efficiency: %s"); + addStringLocalization("Item_DESCRIPTION_Index_006", "Fuel | Optimal Flow > EU/t Produced | Efficiency"); addStringLocalization("Item_DESCRIPTION_Index_007", "Energy from Optimal Gas Flow: %s EU/t"); addStringLocalization("Item_DESCRIPTION_Index_008", "Energy from Optimal Plasma Flow: %s EU/t"); addStringLocalization("Item_DESCRIPTION_Index_009", "Contains %s EU Tier: %s"); diff --git a/src/main/java/gregtech/api/util/TurbineStatCalculator.java b/src/main/java/gregtech/api/util/TurbineStatCalculator.java new file mode 100644 index 0000000000..48c00dfe09 --- /dev/null +++ b/src/main/java/gregtech/api/util/TurbineStatCalculator.java @@ -0,0 +1,140 @@ +package gregtech.api.util; + +// import static gregtech.api.items.GT_MetaGenerated_Tool.getToolMaxDamage; +// import static gregtech.api.items.GT_MetaGenerated_Tool.getPrimaryMaterial; +// import gregtech.api.items.GT_MetaGenerated_Tool.getToolStats; +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.IToolStats; +import gregtech.api.items.MetaGeneratedTool; + +public class TurbineStatCalculator { + + public MetaGeneratedTool turbine; + public ItemStack item; + public long tMaxDamage; + public Materials tMaterial; + public IToolStats tStats; + + public TurbineStatCalculator(MetaGeneratedTool turbineItem, ItemStack aStack) { + turbine = turbineItem; + item = aStack; + tMaxDamage = turbine.getToolMaxDamage(aStack); + tMaterial = turbine.getPrimaryMaterial(aStack); + tStats = turbine.getToolStats(aStack); + } + + // Base stats + + public long getMaxDurability() { + return tMaxDamage; + } + + public long getCurrentDurability() { + return getMaxDurability() - turbine.getToolDamage(item); + } + + // Efficiency in percentages + public float getEfficiency() { + return 0.5F + (0.5F + turbine.getToolCombatDamage(item)) * 0.1F; + } + + public float getSteamEfficiency() { + return getEfficiency(); + } + + public float getGasEfficiency() { + return getEfficiency(); + } + + public float getPlasmaEfficiency() { + return getEfficiency(); + } + + public float getLooseEfficiency() { + // 0.85x - 0.3, where x is the base efficiency + return (float) (-0.2f + Math.round(getEfficiency() * 85.0f) * 0.01); + } + + public float getLooseSteamEfficiency() { + return getLooseEfficiency() * 0.9f; + } + + public float getLooseGasEfficiency() { + return getLooseEfficiency() * 0.95f; + } + + public float getLoosePlasmaEfficiency() { + return getLooseEfficiency(); + } + + // Base optimal flows + + public float getOptimalFlow() { + return tStats.getSpeedMultiplier() * tMaterial.mToolSpeed * 50F; + } + + // All values are in EU/t before efficiency + public float getOptimalSteamFlow() { + return getOptimalFlow() * tMaterial.mSteamMultiplier; + } + + public float getOptimalGasFlow() { + return getOptimalFlow() * tMaterial.mGasMultiplier; + } + + public float getOptimalPlasmaFlow() { + return getOptimalFlow() * tMaterial.mPlasmaMultiplier * 42; + } + + // Loose optimal flows + + public float getOptimalLooseSteamFlow() { + // 3 * 1.1^((Efficiency - 0.8) * 20) + return 3.0f * getOptimalSteamFlow() * (float) Math.pow(1.1f, ((getEfficiency() - 0.8f)) * 20f); + } + + public float getOptimalLooseGasFlow() { + // 2 * 1.05^((Efficiency - 0.8) * 20) + return 2.0f * getOptimalGasFlow() * (float) Math.pow(1.05f, ((getEfficiency() - 0.8f)) * 20f); + } + + public float getOptimalLoosePlasmaFlow() { + // 1 * 1.05^((Efficiency - 0.8) * 20) + return 2.0f * getOptimalPlasmaFlow() * (float) Math.pow(1.03f, ((getEfficiency() - 0.8f)) * 20f); + } + + // Base EU/t from optimal flow + + public float getOptimalSteamEUt() { + return getOptimalSteamFlow() * getSteamEfficiency() * 0.5f; + } + + public float getOptimalGasEUt() { + return getOptimalGasFlow() * getGasEfficiency(); + } + + public float getOptimalPlasmaEUt() { + return getOptimalPlasmaFlow() * getPlasmaEfficiency(); + } + + // Loose EU/t from optimal flow + + public float getOptimalLooseSteamEUt() { + return getOptimalLooseSteamFlow() * getLooseSteamEfficiency() * 0.5f; + } + + public float getOptimalLooseGasEUt() { + return getOptimalLooseGasFlow() * getLooseGasEfficiency(); + } + + public float getOptimalLoosePlasmaEUt() { + return getOptimalLoosePlasmaFlow() * getLoosePlasmaEfficiency(); + } + + public int getOverflowEfficiency() { + return (int) (1 + Math.min(2.0, tMaterial.mToolQuality / 3)); + } + +} 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; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineGas.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineGas.java index e57a7d7e77..31450cc303 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineGas.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineGas.java @@ -25,6 +25,7 @@ import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.recipe.maps.FuelBackend; import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; +import gregtech.api.util.TurbineStatCalculator; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @SuppressWarnings("deprecation") @@ -111,7 +112,7 @@ public class MTELargeTurbineGas extends MTELargerTurbineBase { } @Override - long fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { + long fluidIntoPower(ArrayList<FluidStack> aFluids, TurbineStatCalculator turbine) { if (aFluids.size() >= 1) { int tEU = 0; int actualOptimalFlow = 0; @@ -119,17 +120,19 @@ public class MTELargeTurbineGas extends MTELargerTurbineBase { // Doesn't matter which one. Ignore the rest! int fuelValue = getFuelValue(firstFuelType); // log("Fuel Value of "+aFluids.get(0).getLocalizedName()+" is "+fuelValue+"eu"); - 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 * (double) flowMultipliers[1] / fuelValue)); + actualOptimalFlow = GTUtility.safeInt( + (long) (getSpeedMultiplier() + * ((isLooseMode() ? turbine.getOptimalLooseGasFlow() : turbine.getOptimalGasFlow()) / fuelValue))); this.realOptFlow = actualOptimalFlow; int remainingFlow = GTUtility.safeInt((long) (actualOptimalFlow * 1.25f)); // Allowed to use up to 125% of @@ -154,11 +157,13 @@ public class MTELargeTurbineGas extends MTELargerTurbineBase { tEU = GTUtility.safeInt((long) totalFlow * fuelValue); if (totalFlow == actualOptimalFlow) { - tEU = GTUtility.safeInt((long) tEU * (long) aBaseEff / 10000L); + tEU = GTUtility.safeInt( + (long) (tEU * (isLooseMode() ? turbine.getLooseGasEfficiency() : turbine.getGasEfficiency()))); } else { float efficiency = 1.0f - Math.abs((totalFlow - actualOptimalFlow) / (float) actualOptimalFlow); tEU *= efficiency; - tEU = GTUtility.safeInt((long) tEU * (long) aBaseEff / 10000L); + tEU = GTUtility.safeInt( + (long) (tEU * (isLooseMode() ? turbine.getLooseGasEfficiency() : turbine.getGasEfficiency()))); } return tEU; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSCSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSCSteam.java index 0ef3ef0256..a608cbfc07 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSCSteam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSCSteam.java @@ -6,17 +6,23 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import gregtech.api.enums.Materials; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GTModHandler; import gregtech.api.util.GTUtility; +import gregtech.api.util.TurbineStatCalculator; +import gtPlusPlus.core.lib.GTPPCore; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; public class MTELargeTurbineSCSteam extends MTELargerTurbineBase { + private boolean hasConsumedSteam; + private boolean isUsingDenseSteam; + public MTELargeTurbineSCSteam(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -56,47 +62,88 @@ public class MTELargeTurbineSCSteam extends MTELargerTurbineBase { } @Override - long fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { + long fluidIntoPower(ArrayList<FluidStack> aFluids, TurbineStatCalculator turbine) { + int tEU = 0; int totalFlow = 0; // Byproducts are based on actual flow int flow = 0; + float denseFlow = 0; + float steamFlowForNextSteam = 0; + int steamInHatch = 0; // Variable required outside of loop for // multi-hatch scenarios. - this.realOptFlow = aOptFlow; + this.realOptFlow = getSpeedMultiplier() + * (looseFit ? turbine.getOptimalLooseSteamFlow() : turbine.getOptimalSteamFlow()); // this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0]; // Will there be an multiplier for SC? int remainingFlow = MathUtils.safeInt((long) (realOptFlow * 1.25f)); // Allowed to use up to // 125% of optimal flow. + float remainingDenseFlow = 0; storedFluid = 0; FluidStack tSCSteam = FluidRegistry.getFluidStack("supercriticalsteam", 1); for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { + String fluidName = aFluids.get(i) + .getFluid() + .getUnlocalizedName(aFluids.get(i)); if (GTUtility.areFluidsEqual(aFluids.get(i), tSCSteam, true)) { + if (!hasConsumedSteam) { + hasConsumedSteam = true; + isUsingDenseSteam = false; + } else if (isUsingDenseSteam) { + continue; + } flow = Math.min(aFluids.get(i).amount, remainingFlow); // try to use up w/o exceeding remainingFlow depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount this.storedFluid += aFluids.get(i).amount; remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches totalFlow += flow; // track total input used + } else if (fluidName.equals("fluid.densesupercriticalsteam")) { + if (!hasConsumedSteam) { + hasConsumedSteam = true; + isUsingDenseSteam = true; + } else if (!isUsingDenseSteam) { + continue; + } + steamInHatch = aFluids.get(i).amount; + remainingDenseFlow = (float) remainingFlow / 1000; // Dense Steam is 1000x the EU value + denseFlow = Math.min(steamInHatch, remainingDenseFlow); // try to use up w/o exceeding + // remainingDenseFlow + depleteInput(new FluidStack(aFluids.get(i), (int) denseFlow)); // deplete that amount + this.storedFluid += aFluids.get(i).amount; + remainingFlow -= denseFlow * 1000; // track amount we're allowed to continue depleting from hatches + totalFlow += denseFlow * 1000; // track total input used + steamFlowForNextSteam += denseFlow; } } if (totalFlow <= 0) return 0; - tEU = totalFlow; - addOutput(GTModHandler.getSteam(totalFlow * 100)); + tEU = totalFlow; // SC Steam has 1 EU per litre so the flow equals base EU produced + if (isUsingDenseSteam) { + addOutput(Materials.DenseSuperheatedSteam.getGas((long) steamFlowForNextSteam)); + } else { + addOutput(GTModHandler.getSteam(totalFlow * 100)); + } if (totalFlow != realOptFlow) { float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow); // if(totalFlow>aOptFlow){efficiency = 1.0f;} tEU *= efficiency; - tEU = Math.max(1, MathUtils.safeInt((long) tEU * (long) aBaseEff / 10000L)); + tEU = Math.max( + 1, + MathUtils.safeInt( + (long) (tEU * (looseFit ? turbine.getLooseSteamEfficiency() : turbine.getSteamEfficiency())))); } else { - tEU = MathUtils.safeInt((long) tEU * (long) aBaseEff / 10000L); + tEU = MathUtils + .safeInt((long) (tEU * (looseFit ? turbine.getLooseSteamEfficiency() : turbine.getSteamEfficiency()))); + } + if (isUsingDenseSteam) { + return tEU; } - return tEU * 100L; } @Override public int getDamageToComponent(ItemStack aStack) { - return 8; + return (looseFit && GTPPCore.RANDOM.nextInt(4) == 0) ? 0 : 1; } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSHSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSHSteam.java index 7fdc36450d..afa13de0be 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSHSteam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSHSteam.java @@ -2,29 +2,26 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.t import java.util.ArrayList; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import gregtech.GTMod; +import gregtech.api.enums.Materials; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GTRenderedTexture; import gregtech.api.util.GTModHandler; -import gregtech.api.util.GTUtility; +import gregtech.api.util.TurbineStatCalculator; import gtPlusPlus.core.lib.GTPPCore; import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @SuppressWarnings("deprecation") public class MTELargeTurbineSHSteam extends MTELargerTurbineBase { public boolean achievement = false; - private boolean looseFit = false; + private boolean isUsingDenseSteam; public MTELargeTurbineSHSteam(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -65,119 +62,107 @@ public class MTELargeTurbineSHSteam extends MTELargerTurbineBase { } @Override - long fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { - if (looseFit) { - aOptFlow *= 4; - if (aBaseEff > 10000) { - aOptFlow *= Math.pow(1.1f, ((aBaseEff - 7500) / 10000F) * 20f); - aBaseEff = 7500; - } else if (aBaseEff > 7500) { - aOptFlow *= Math.pow(1.1f, ((aBaseEff - 7500) / 10000F) * 20f); - aBaseEff *= 0.75f; - } else { - aBaseEff *= 0.75f; - } - } - // prevent overflow like that in SC Steam + long fluidIntoPower(ArrayList<FluidStack> aFluids, TurbineStatCalculator turbine) { + long tEU = 0; int totalFlow = 0; // Byproducts are based on actual flow int flow = 0; + float denseFlow = 0; + float steamFlowForNextSteam = 0; + int steamInHatch = 0; // Variable required outside of loop for // multi-hatch scenarios. - this.realOptFlow = aOptFlow * flowMultipliers[0]; + this.realOptFlow = getSpeedMultiplier() + * (looseFit ? turbine.getOptimalLooseSteamFlow() : turbine.getOptimalSteamFlow()); int remainingFlow = MathUtils.safeInt((long) (realOptFlow * 1.25f)); // Allowed to use up to // 125% of optimal flow. + float remainingDenseFlow = 0; + + boolean hasConsumedSteam = false; storedFluid = 0; for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { String fluidName = aFluids.get(i) .getFluid() .getUnlocalizedName(aFluids.get(i)); - if (fluidName.equals("ic2.fluidSuperheatedSteam")) { - flow = Math.min(aFluids.get(i).amount, remainingFlow); // try to use up w/o exceeding remainingFlow - depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount - this.storedFluid += aFluids.get(i).amount; - remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches - totalFlow += flow; // track total input used - if (!achievement) { - try { - GTMod.achievements.issueAchievement( - this.getBaseMetaTileEntity() - .getWorld() - .getPlayerEntityByName( - this.getBaseMetaTileEntity() - .getOwnerName()), - "efficientsteam"); - } catch (Exception e) {} - achievement = true; + switch (fluidName) { + case "ic2.fluidSuperheatedSteam" -> { + if (!hasConsumedSteam) { + hasConsumedSteam = true; + isUsingDenseSteam = false; + } else if (isUsingDenseSteam) { + continue; + } + flow = Math.min(aFluids.get(i).amount, remainingFlow); // try to use up w/o exceeding remainingFlow + depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount + this.storedFluid += aFluids.get(i).amount; + remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches + totalFlow += flow; // track total input used + if (!achievement) { + try { + GTMod.achievements.issueAchievement( + this.getBaseMetaTileEntity() + .getWorld() + .getPlayerEntityByName( + this.getBaseMetaTileEntity() + .getOwnerName()), + "efficientsteam"); + } catch (Exception e) {} + achievement = true; + } } - } else if (fluidName.equals("fluid.steam") || fluidName.equals("ic2.fluidSteam") - || fluidName.equals("fluid.mfr.steam.still.name")) { - depleteInput(new FluidStack(aFluids.get(i), aFluids.get(i).amount)); + case "fluid.densesuperheatedsteam" -> { + if (!hasConsumedSteam) { + hasConsumedSteam = true; + isUsingDenseSteam = true; + } else if (!isUsingDenseSteam) { + continue; + } + steamInHatch = aFluids.get(i).amount; + remainingDenseFlow = (float) remainingFlow / 1000; // Dense Steam is 1000x the EU value + denseFlow = Math.min(steamInHatch, remainingDenseFlow); // try to use up w/o exceeding + // remainingDenseFlow + depleteInput(new FluidStack(aFluids.get(i), (int) denseFlow)); // deplete that amount + this.storedFluid += aFluids.get(i).amount; + remainingFlow -= denseFlow * 1000; // track amount we're allowed to continue depleting from hatches + totalFlow += denseFlow * 1000; // track total input used + steamFlowForNextSteam += denseFlow; } + case "fluid.steam", "ic2.fluidSteam", "fluid.mfr.steam.still.name" -> depleteInput( + new FluidStack(aFluids.get(i), aFluids.get(i).amount)); + } } if (totalFlow <= 0) return 0; - tEU = totalFlow; - addOutput(GTModHandler.getSteam(totalFlow)); + tEU = totalFlow; // SH Steam has 1 EU per litre so the flow equals base EU produced + if (isUsingDenseSteam) { + addOutput(Materials.DenseSteam.getGas((long) steamFlowForNextSteam)); + } else { + addOutput(GTModHandler.getSteam(totalFlow)); + } if (totalFlow != realOptFlow) { float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow); // if(totalFlow>aOptFlow){efficiency = 1.0f;} tEU *= efficiency; - tEU = Math.max(1L, tEU * aBaseEff / 10000L); + tEU = Math.max( + 1, + MathUtils.safeInt( + (long) (tEU * (looseFit ? turbine.getLooseSteamEfficiency() : turbine.getSteamEfficiency())))); } else { - tEU = tEU * aBaseEff / 10000L; + tEU = MathUtils + .safeInt((long) (tEU * (looseFit ? turbine.getLooseSteamEfficiency() : turbine.getSteamEfficiency()))); } return tEU; } @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - // Using a screwdriver to change modes should allow for any combination of Slow/Fast and Tight/Loose Mode - // Whenever there's a mode switch, there will be two messages on the player chat - // The two messages specify which two modes the turbine is on after the change - // (Tight/Loose changes on every action, Slow/Fast changes every other action, all pairs are cycled this way) - if (side == getBaseMetaTileEntity().getFrontFacing()) { - looseFit ^= true; - GTUtility.sendChatToPlayer( - aPlayer, - looseFit ? "Fitting is Loose (Higher Flow)" : "Fitting is Tight (Higher Efficiency)"); - } - - if (looseFit) { - super.onModeChangeByScrewdriver(side, aPlayer, aX, aY, aZ); - } else if (mFastMode) { - PlayerUtils.messagePlayer(aPlayer, "Running in Fast (48x) Mode."); - } else { - PlayerUtils.messagePlayer(aPlayer, "Running in Slow (16x) Mode."); - } - } - - @Override public int getDamageToComponent(ItemStack aStack) { return (looseFit && GTPPCore.RANDOM.nextInt(4) == 0) ? 0 : 1; } @Override - public boolean isLooseMode() { - return looseFit; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("turbineFitting", looseFit); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - looseFit = aNBT.getBoolean("turbineFitting"); - } - - @Override public String getMachineType() { return "Large Super-heated Steam Turbine"; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSteam.java index 68cfc8cd1e..72a50cacf3 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSteam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSteam.java @@ -4,10 +4,7 @@ import static gtPlusPlus.core.lib.GTPPCore.RANDOM; import java.util.ArrayList; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import gregtech.GTMod; @@ -16,9 +13,8 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GTRenderedTexture; import gregtech.api.util.GTModHandler; -import gregtech.api.util.GTUtility; +import gregtech.api.util.TurbineStatCalculator; import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @SuppressWarnings("deprecation") @@ -26,7 +22,7 @@ public class MTELargeTurbineSteam extends MTELargerTurbineBase { private float water; private boolean achievement = false; - private boolean looseFit = false; + private boolean isUsingDenseSteam; public MTELargeTurbineSteam(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -74,32 +70,27 @@ public class MTELargeTurbineSteam extends MTELargerTurbineBase { } @Override - long fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { - if (looseFit) { - aOptFlow *= 4; - if (aBaseEff > 10000) { - aOptFlow *= Math.pow(1.1f, ((aBaseEff - 7500) / 10000F) * 20f); - aBaseEff = 7500; - } else if (aBaseEff > 7500) { - aOptFlow *= Math.pow(1.1f, ((aBaseEff - 7500) / 10000F) * 20f); - aBaseEff *= 0.75f; - } else { - aBaseEff *= 0.75f; - } - } - // prevent overflow like that in SC Steam + long fluidIntoPower(ArrayList<FluidStack> aFluids, TurbineStatCalculator turbine) { + long tEU = 0; int totalFlow = 0; // Byproducts are based on actual flow int flow = 0; + float denseFlow = 0; + float steamFlowForWater = 0; + int steamInHatch = 0; // Variable required outside of loop for // multi-hatch scenarios. - this.realOptFlow = aOptFlow * flowMultipliers[0]; + this.realOptFlow = getSpeedMultiplier() + * (looseFit ? turbine.getOptimalLooseSteamFlow() : turbine.getOptimalSteamFlow()); int remainingFlow = MathUtils.safeInt((long) (realOptFlow * 1.25f)); // Allowed to // use up to // 125% of // optimal flow. + float remainingDenseFlow = 0; + + boolean hasConsumedSteam = false; storedFluid = 0; for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { // loop through each hatch; extract inputs and @@ -107,88 +98,82 @@ public class MTELargeTurbineSteam extends MTELargerTurbineBase { String fluidName = aFluids.get(i) .getFluid() .getUnlocalizedName(aFluids.get(i)); - if (fluidName.equals("fluid.steam") || fluidName.equals("ic2.fluidSteam") - || fluidName.equals("fluid.mfr.steam.still.name")) { - flow = Math.min(aFluids.get(i).amount, remainingFlow); // try to use up w/o exceeding remainingFlow - depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount - this.storedFluid += aFluids.get(i).amount; - remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches - totalFlow += flow; // track total input used - if (!achievement) { - GTMod.achievements.issueAchievement( - this.getBaseMetaTileEntity() - .getWorld() - .getPlayerEntityByName( - this.getBaseMetaTileEntity() - .getOwnerName()), - "muchsteam"); - achievement = true; + switch (fluidName) { + case "fluid.steam", "ic2.fluidSteam", "fluid.mfr.steam.still.name" -> { + if (!hasConsumedSteam) { + hasConsumedSteam = true; + isUsingDenseSteam = false; + } else if (isUsingDenseSteam) { + continue; + } + flow = Math.min(aFluids.get(i).amount, remainingFlow); // try to use up w/o exceeding remainingFlow + depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount + this.storedFluid += aFluids.get(i).amount; + remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches + totalFlow += flow; // track total input used + if (!achievement) { + GTMod.achievements.issueAchievement( + this.getBaseMetaTileEntity() + .getWorld() + .getPlayerEntityByName( + this.getBaseMetaTileEntity() + .getOwnerName()), + "muchsteam"); + achievement = true; + } + } + case "fluid.densesteam" -> { + if (!hasConsumedSteam) { + hasConsumedSteam = true; + isUsingDenseSteam = true; + } else if (!isUsingDenseSteam) { + continue; + } + steamInHatch = aFluids.get(i).amount; + remainingDenseFlow = (float) remainingFlow / 1000; // Dense Steam is 1000x the EU value + denseFlow = Math.min(steamInHatch, remainingDenseFlow); // try to use up w/o exceeding + // remainingDenseFlow + depleteInput(new FluidStack(aFluids.get(i), (int) denseFlow)); // deplete that amount + this.storedFluid += aFluids.get(i).amount; + remainingFlow -= denseFlow * 1000; // track amount we're allowed to continue depleting from hatches + totalFlow += denseFlow * 1000; // track total input used + steamFlowForWater += denseFlow * 1000; } - } else if (fluidName.equals("ic2.fluidSuperheatedSteam")) { - depleteInput(new FluidStack(aFluids.get(i), aFluids.get(i).amount)); + case "ic2.fluidSuperheatedSteam" -> depleteInput(new FluidStack(aFluids.get(i), aFluids.get(i).amount)); } } if (totalFlow <= 0) return 0; - tEU = totalFlow; - int waterToOutput = useWater(totalFlow / 160.0f); + tEU = (long) (totalFlow * 0.5f); + int waterToOutput; + if (isUsingDenseSteam) { + // Water return is lower to counteract water generation from rounding errors + waterToOutput = useWater(steamFlowForWater / 160.1f); + } else { + waterToOutput = useWater(totalFlow / 160.0f); + } addOutput(GTModHandler.getDistilledWater(waterToOutput)); if (totalFlow != realOptFlow) { float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow); // if(totalFlow>aOptFlow){efficiency = 1.0f;} tEU *= efficiency; - tEU = Math.max(1L, tEU * aBaseEff / 20000L); + tEU = Math.max( + 1, + MathUtils.safeInt( + (long) (tEU * (looseFit ? turbine.getLooseSteamEfficiency() : turbine.getSteamEfficiency())))); } else { - tEU = tEU * aBaseEff / 20000L; + tEU = MathUtils + .safeInt((long) (tEU * (looseFit ? turbine.getLooseSteamEfficiency() : turbine.getSteamEfficiency()))); } return tEU; } @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - // Using a screwdriver to change modes should allow for any combination of Slow/Fast and Tight/Loose Mode - // Whenever there's a mode switch, there will be two messages on the player chat - // The two messages specify which two modes the turbine is on after the change - // (Tight/Loose changes on every action, Slow/Fast changes every other action, all pairs are cycled this way) - if (side == getBaseMetaTileEntity().getFrontFacing()) { - looseFit ^= true; - GTUtility.sendChatToPlayer( - aPlayer, - looseFit ? "Fitting: Loose - More Flow" : "Fitting: Tight - More Efficiency"); - } - - if (looseFit) { - super.onModeChangeByScrewdriver(side, aPlayer, aX, aY, aZ); - } else if (mFastMode) { - PlayerUtils.messagePlayer(aPlayer, "Running in Fast (48x) Mode."); - } else { - PlayerUtils.messagePlayer(aPlayer, "Running in Slow (16x) Mode."); - } - } - - @Override public int getDamageToComponent(ItemStack aStack) { return (looseFit && RANDOM.nextInt(4) == 0) ? 0 : 1; } @Override - public boolean isLooseMode() { - return looseFit; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("turbineFitting", looseFit); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - looseFit = aNBT.getBoolean("turbineFitting"); - } - - @Override public String getMachineType() { return "Large Steam Turbine"; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargerTurbineBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargerTurbineBase.java index 0bd1397137..079983e337 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargerTurbineBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargerTurbineBase.java @@ -45,6 +45,7 @@ import gregtech.api.recipe.check.CheckRecipeResult; import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.TurbineStatCalculator; import gregtech.api.util.shutdown.ShutDownReason; import gregtech.api.util.shutdown.ShutDownReasonRegistry; import gtPlusPlus.api.objects.Logger; @@ -53,7 +54,6 @@ import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.GTPPCore; import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.MTEHatchTurbine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; @@ -67,7 +67,7 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase<MTELargerT protected double realOptFlow = 0; protected int storedFluid = 0; protected int counter = 0; - protected boolean mFastMode = false; + protected boolean looseFit = false; protected double mufflerReduction = 1; protected float[] flowMultipliers = new float[] { 1, 1, 1 }; @@ -104,10 +104,9 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase<MTELargerT tt.addMachineType(getMachineType()) .addInfo("Controller Block for the XL " + getTurbineType() + " Turbine") .addInfo("Runs as fast as 16 Large Turbines of the same type, takes the space of 12") - .addInfo("Right-click with screwdriver to enable Fast Mode, to run it even faster") - .addInfo("Optimal flow will increase or decrease accordingly on mode switch") - .addInfo("Fast Mode increases speed to 48x instead of 16x, with some penalties") - .addInfo("Maintenance problems and turbine damage happen 12x as often in Fast Mode"); + .addInfo("Right-click with screwdriver to enable loose fit") + .addInfo("Optimal flow will increase or decrease depending on fitting") + .addInfo("Loose fit increases flow in exchange for efficiency"); if (getTurbineType().contains("Steam")) { tt.addInfo("XL Steam Turbines can use Loose Mode with either Slow or Fast Mode"); } @@ -116,7 +115,6 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase<MTELargerT .addInfo("Efficiency = ((FuelValue / 200,000)^2) / (EU per Turbine)"); } tt.addPollutionAmount(getPollutionPerSecond(null)) - .addInfo("Pollution is 3x higher in Fast Mode") .addSeparator() .beginStructureBlock(7, 9, 7, false) .addController("Top Middle") @@ -450,6 +448,11 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase<MTELargerT ArrayList<FluidStack> tFluids = getStoredFluids(); + ItemStack aStack = getFullTurbineAssemblies().get(0) + .getTurbine(); + + TurbineStatCalculator turbine = new TurbineStatCalculator((MetaGeneratedTool) aStack.getItem(), aStack); + if (tFluids.size() > 0) { if (baseEff == 0 || optFlow == 0 || counter >= 512 @@ -461,25 +464,15 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase<MTELargerT float aTotalBaseEff = 0; float aTotalOptimalFlow = 0; - ItemStack aStack = getFullTurbineAssemblies().get(0) - .getTurbine(); - aTotalBaseEff += GTUtility.safeInt( - (long) ((5F + ((MetaGeneratedTool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F)); - aTotalOptimalFlow += GTUtility.safeInt( - (long) Math.max( - Float.MIN_NORMAL, - ((MetaGeneratedTool) aStack.getItem()).getToolStats(aStack) - .getSpeedMultiplier() * MetaGeneratedTool.getPrimaryMaterial(aStack).mToolSpeed * 50) - * getSpeedMultiplier()); + aTotalBaseEff += turbine.getEfficiency() * 100; + aTotalOptimalFlow += GTUtility + .safeInt((long) Math.max(Float.MIN_NORMAL, getSpeedMultiplier() * turbine.getOptimalFlow())); + baseEff = MathUtils.roundToClosestInt(aTotalBaseEff); + optFlow = MathUtils.roundToClosestInt(aTotalOptimalFlow); if (aTotalOptimalFlow < 0) { aTotalOptimalFlow = 100; } - flowMultipliers[0] = MetaGeneratedTool.getPrimaryMaterial(aStack).mSteamMultiplier; - flowMultipliers[1] = MetaGeneratedTool.getPrimaryMaterial(aStack).mGasMultiplier; - flowMultipliers[2] = MetaGeneratedTool.getPrimaryMaterial(aStack).mPlasmaMultiplier; - baseEff = MathUtils.roundToClosestInt(aTotalBaseEff); - optFlow = MathUtils.roundToClosestInt(aTotalOptimalFlow); if (optFlow <= 0 || baseEff <= 0) { stopMachine(ShutDownReasonRegistry.NONE); // in case the turbine got removed return CheckRecipeResultRegistry.NO_FUEL_FOUND; @@ -490,7 +483,7 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase<MTELargerT } // How much the turbine should be producing with this flow - long newPower = fluidIntoPower(tFluids, optFlow, baseEff, flowMultipliers); + long newPower = fluidIntoPower(tFluids, turbine); long difference = newPower - this.lEUt; // 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 @@ -554,7 +547,7 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase<MTELargerT return (getFullTurbineAssemblies().size()); } - abstract long fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers); + abstract long fluidIntoPower(ArrayList<FluidStack> aFluids, TurbineStatCalculator turbine); @Override public int getDamageToComponent(ItemStack aStack) { @@ -572,7 +565,7 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase<MTELargerT } public boolean isLooseMode() { - return false; + return looseFit; } @Override @@ -694,33 +687,28 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase<MTELargerT @Override public long maxAmperesOut() { - // This should not be a hard limit, due to TecTech dynamos - if (mFastMode) { - return 64; - } else { - return 16; - } + return 16; } @Override public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("mFastMode", mFastMode); super.saveNBTData(aNBT); + aNBT.setBoolean("turbineFitting", looseFit); } @Override public void loadNBTData(NBTTagCompound aNBT) { - mFastMode = aNBT.getBoolean("mFastMode"); super.loadNBTData(aNBT); + looseFit = aNBT.getBoolean("turbineFitting"); } @Override public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mFastMode = !mFastMode; - if (mFastMode) { - PlayerUtils.messagePlayer(aPlayer, "Running in Fast (48x) Mode."); - } else { - PlayerUtils.messagePlayer(aPlayer, "Running in Slow (16x) Mode."); + if (side == getBaseMetaTileEntity().getFrontFacing()) { + looseFit ^= true; + GTUtility.sendChatToPlayer( + aPlayer, + looseFit ? "Fitting: Loose - More Flow" : "Fitting: Tight - More Efficiency"); } } @@ -862,19 +850,19 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase<MTELargerT } public int getSpeedMultiplier() { - return mFastMode ? 48 : 16; + return 16; } public int getMaintenanceThreshold() { - return mFastMode ? 12 : 1; + return 1; } public int getPollutionMultiplier() { - return mFastMode ? 3 : 1; + return 1; } public int getTurbineDamageMultiplier() { - return mFastMode ? 3 : 1; + return 1; } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbinePlasma.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargerTurbinePlasma.java index 310463e0d5..9947cc6350 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbinePlasma.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargerTurbinePlasma.java @@ -23,27 +23,28 @@ import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.recipe.maps.FuelBackend; import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; +import gregtech.api.util.TurbineStatCalculator; import gregtech.api.util.shutdown.ShutDownReasonRegistry; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.MTEHatchTurbine; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @SuppressWarnings("deprecation") -public class MTELargeTurbinePlasma extends MTELargerTurbineBase { +public class MTELargerTurbinePlasma extends MTELargerTurbineBase { private static final HashSet<Fluid> BLACKLIST = new HashSet<>(); - public MTELargeTurbinePlasma(int aID, String aName, String aNameRegional) { + public MTELargerTurbinePlasma(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public MTELargeTurbinePlasma(String aName) { + public MTELargerTurbinePlasma(String aName) { super(aName); } @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new MTELargeTurbinePlasma(mName); + return new MTELargerTurbinePlasma(mName); } @Override @@ -119,6 +120,14 @@ public class MTELargeTurbinePlasma extends MTELargerTurbineBase { return CheckRecipeResultRegistry.NO_TURBINE_FOUND; } + // At this point all turbines are equivalent in all hatches, use the stats of the first turbine for + // calculations + ItemStack turbineItem = mTurbineRotorHatches.get(0) + .getTurbine(); + TurbineStatCalculator turbine = new TurbineStatCalculator( + (MetaGeneratedTool) turbineItem.getItem(), + turbineItem); + ArrayList<FluidStack> tFluids = getStoredFluids(); if (tFluids.size() > 0) { @@ -140,21 +149,11 @@ public class MTELargeTurbinePlasma extends MTELargerTurbineBase { ItemStack aStack = getFullTurbineAssemblies().get(0) .getTurbine(); - aTotalBaseEff += GTUtility.safeInt( - (long) ((5F + ((MetaGeneratedTool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F)); - aTotalOptimalFlow += GTUtility - .safeInt( - (long) Math.max( - Float.MIN_NORMAL, - ((MetaGeneratedTool) aStack.getItem()).getToolStats(aStack) - .getSpeedMultiplier() * MetaGeneratedTool.getPrimaryMaterial(aStack).mToolSpeed - * 50)); + aTotalBaseEff += turbine.getPlasmaEfficiency() * 10000; + aTotalOptimalFlow += turbine.getOptimalPlasmaFlow(); // Calculate total EU/t (as shown on turbine tooltip (Fast mode doesn't affect)) - double aEUPerTurbine = aTotalOptimalFlow * 40 - * 0.0105 - * MetaGeneratedTool.getPrimaryMaterial(aStack).mPlasmaMultiplier - * (50.0f + (10.0f * ((MetaGeneratedTool) aStack.getItem()).getToolCombatDamage(aStack))); + double aEUPerTurbine = turbine.getOptimalPlasmaEUt(); aTotalOptimalFlow *= getSpeedMultiplier(); if (aTotalOptimalFlow < 0) { @@ -177,7 +176,7 @@ public class MTELargeTurbinePlasma extends MTELargerTurbineBase { } // How much the turbine should be producing with this flow - long newPower = fluidIntoPower(tFluids, optFlow, baseEff, flowMultipliers); + long newPower = fluidIntoPower(tFluids, turbine); // Reduce produced power depending on the ratio between fuel value and turbine EU/t with the following // formula: @@ -198,7 +197,7 @@ public class MTELargeTurbinePlasma extends MTELargerTurbineBase { int maxChangeAllowed = Math.max(10, GTUtility.safeInt((long) Math.abs(difference) / 100)); if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed - // change + // change int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative. this.lEUt += change; // Apply the change } else { @@ -210,7 +209,7 @@ public class MTELargeTurbinePlasma extends MTELargerTurbineBase { return CheckRecipeResultRegistry.NO_FUEL_FOUND; } else { this.mMaxProgresstime = 20; - this.mEfficiencyIncrease = 10; + 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) enableAllTurbineHatches(); @@ -222,24 +221,24 @@ public class MTELargeTurbinePlasma extends MTELargerTurbineBase { return CheckRecipeResultRegistry.NO_FUEL_FOUND; } - @Override - long fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { + long 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 * (double) flowMultipliers[2] / (double) fuelValue)); + actualOptimalFlow = GTUtility.safeInt( + (long) ((getSpeedMultiplier() + * (isLooseMode() ? turbine.getOptimalLoosePlasmaFlow() : turbine.getOptimalPlasmaFlow()) + * 20) / (double) fuelValue)); // Check recipe runs once every 20 ticks this.realOptFlow = actualOptimalFlow; // For scanner info int remainingFlow = GTUtility.safeInt((long) (actualOptimalFlow * 1.25f)); // Allowed to use up to 125% of - // optimal flow. Variable - // required outside of loop for + // optimal flow. Variable + // required outside of loop for // multi-hatch scenarios. int flow = 0; int totalFlow = 0; @@ -270,12 +269,16 @@ public class MTELargeTurbinePlasma extends MTELargerTurbineBase { tEU = GTUtility.safeInt((long) ((fuelValue / 20D) * (double) totalFlow)); if (totalFlow == actualOptimalFlow) { - tEU = GTUtility.safeInt((long) (aBaseEff / 10000D * tEU)); + tEU = GTUtility.safeInt( + (long) ((isLooseMode() ? turbine.getLoosePlasmaEfficiency() : turbine.getPlasmaEfficiency()) + * tEU)); } else { double efficiency = 1.0D - Math.abs((totalFlow - actualOptimalFlow) / (float) actualOptimalFlow); tEU = (int) (tEU * efficiency); - tEU = GTUtility.safeInt((long) (aBaseEff / 10000D * tEU)); + tEU = GTUtility.safeInt( + (long) ((isLooseMode() ? turbine.getLoosePlasmaEfficiency() : turbine.getPlasmaEfficiency()) + * tEU)); } return tEU; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechLargeTurbinesAndHeatExchanger.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechLargeTurbinesAndHeatExchanger.java index 580be58352..67d75fe68c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechLargeTurbinesAndHeatExchanger.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechLargeTurbinesAndHeatExchanger.java @@ -13,10 +13,10 @@ import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.MTEHatchTurbine; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced.MTEAdvHeatExchanger; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines.MTELargeTurbineGas; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines.MTELargeTurbinePlasma; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines.MTELargeTurbineSCSteam; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines.MTELargeTurbineSHSteam; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines.MTELargeTurbineSteam; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines.MTELargerTurbinePlasma; public class GregtechLargeTurbinesAndHeatExchanger { @@ -38,7 +38,7 @@ public class GregtechLargeTurbinesAndHeatExchanger { new MTELargeTurbineGas(Large_Gas_Turbine.ID, "multimachine.largergasturbine", "XL Turbo Gas Turbine") .getStackForm(1L)); GregtechItemList.Large_Plasma_Turbine.set( - new MTELargeTurbinePlasma( + new MTELargerTurbinePlasma( Large_Plasma_Turbine.ID, "multimachine.largerplasmaturbine", "XL Turbo Plasma Turbine").getStackForm(1L)); |