Skip to content

Commit

Permalink
Large Large & Larger Turbine Rework (GTNewHorizons#3075)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Mendes <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: NotAPenguin <[email protected]>
Co-authored-by: Martin Robertz <[email protected]>
  • Loading branch information
5 people authored Sep 9, 2024
1 parent abba7f7 commit 4058d5a
Show file tree
Hide file tree
Showing 21 changed files with 674 additions and 651 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ protected MultiblockTooltipBuilder createTooltip() {
.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");
Expand Down Expand Up @@ -268,8 +268,15 @@ public boolean onRunningTick(ItemStack aStack) {
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()
Expand All @@ -281,16 +288,13 @@ public boolean onRunningTick(ItemStack aStack) {
}

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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 {

Expand All @@ -42,27 +43,14 @@ public MTESupercriticalFluidTurbine(String aName) {
}

@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);
Expand All @@ -80,20 +68,24 @@ public int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBase
}
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
Expand Down Expand Up @@ -153,8 +145,7 @@ protected MultiblockTooltipBuilder createTooltip() {
.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")
Expand All @@ -165,6 +156,7 @@ protected MultiblockTooltipBuilder createTooltip() {
.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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
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>
Expand Down Expand Up @@ -79,6 +81,7 @@ protected IStructureDefinition<MTELargeTurbineBase> computeValue(Class<?> type)
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) {
Expand Down Expand Up @@ -140,38 +143,40 @@ public void loadNBTData(NBTTagCompound aNBT) {
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()
.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));
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 {
counter++;
}
}

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
Expand All @@ -197,7 +202,7 @@ public void loadNBTData(NBTTagCompound aNBT) {
}
}

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) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/goodgenerator/loader/RecipeLoader2.java
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,7 @@ public static void InitLoadRecipe() {
.addTo(plasmaForgeRecipes);
}

public static float EHEEfficiencyMultiplier = 1.2f;
public static float EHEEfficiencyMultiplier = 0.9f;

public static void FinishLoadRecipe() {
for (GTRecipe plasmaFuel : RecipeMaps.plasmaFuels.getAllRecipes()) {
Expand Down Expand Up @@ -1872,13 +1872,13 @@ public static void FinishLoadRecipe() {
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);
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/gregtech/api/enums/Materials.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 4058d5a

Please sign in to comment.