diff options
author | Steelux <70096037+Steelux8@users.noreply.github.com> | 2022-07-08 11:29:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-08 17:29:20 +0700 |
commit | 1fa45b64a4168ffe708ea2b47e7385300ebdf2e2 (patch) | |
tree | 44c722dffff3b15d2b305e1730563ff190515cea /src/main/java/gregtech/common/tileentities/machines | |
parent | fbfb60acd568aa851261e9e626aca85c68dfc04c (diff) | |
download | GT5-Unofficial-1fa45b64a4168ffe708ea2b47e7385300ebdf2e2.tar.gz GT5-Unofficial-1fa45b64a4168ffe708ea2b47e7385300ebdf2e2.tar.bz2 GT5-Unofficial-1fa45b64a4168ffe708ea2b47e7385300ebdf2e2.zip |
Add Advanced Gas Turbine and Limit Original LGT (#1106)
* Add Advanced Gas Turbine and Limit Original LGT
- Added an Advanced LGT, made out of HSS-S, that only accepts gas fuels with a fuel value above 800k per bucket;
- Capped the EU/t output of the regular LGT at 8192 EU/t, regardless of dynamo (it will never explode);
* Changed Texture Ordering, Byte to Int and Texture Order
- Reverted the change to existing texture placements in the array to not break already existing multis;
- Changed the output value type of getTextureCasingIndex to int, to support the intended texture.
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/java/gregtech/common/tileentities/machines')
6 files changed, 190 insertions, 6 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java index b5e1db0e6b..05ea85d276 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java @@ -92,7 +92,7 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_E public abstract byte getCasingMeta(); - public abstract byte getCasingTextureIndex(); + public abstract int getCasingTextureIndex(); @Override public boolean addToMachineList(IGregTechTileEntity tTileEntity, int aBaseCasingIndex) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java index f537fbebb8..ff469df2e2 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java @@ -42,6 +42,8 @@ public class GT_MetaTileEntity_LargeTurbine_Gas extends GT_MetaTileEntity_LargeT tt.addMachineType("Gas Turbine") .addInfo("Controller block for the Large Gas Turbine") .addInfo("Needs a Turbine, place inside controller") + .addInfo("Can only produce up to 8192 EU/t, regardless of Dynamo Hatch") + .addInfo("The excess fuel that gets consumed will be voided!") .addPollutionAmount(getPollutionPerSecond(null)) .addSeparator() .beginStructureBlock(3, 3, 4, true) @@ -78,7 +80,7 @@ public class GT_MetaTileEntity_LargeTurbine_Gas extends GT_MetaTileEntity_LargeT } @Override - public byte getCasingTextureIndex() { + public int getCasingTextureIndex() { return 58; } @@ -141,8 +143,14 @@ public class GT_MetaTileEntity_LargeTurbine_Gas extends GT_MetaTileEntity_LargeT tEU = GT_Utility.safeInt((long) tEU * (long) aBaseEff / 10000L); } + // EU/t output cap to properly tier the LGT against the Advanced LGT + if (tEU > 8192) { + tEU = 8192; + } + // If next output is above the maximum the dynamo can handle, set it to the maximum instead of exploding the turbine - // Raising the maximum allowed flow rate to account for the efficiency changes beyond the optimal flow rate can explode turbines on world load + // Raising the maximum allowed flow rate to account for the efficiency changes beyond the optimal flow + // When the max fuel consumption rate was increased, turbines could explode on world load if (tEU > getMaximumOutput()){ tEU = GT_Utility.safeInt(getMaximumOutput()); } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_GasAdvanced.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_GasAdvanced.java new file mode 100644 index 0000000000..9867e7a27e --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_GasAdvanced.java @@ -0,0 +1,176 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +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.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; + +import static gregtech.api.enums.Textures.BlockIcons.*; + +public class GT_MetaTileEntity_LargeTurbine_GasAdvanced extends GT_MetaTileEntity_LargeTurbine { + public GT_MetaTileEntity_LargeTurbine_GasAdvanced(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_LargeTurbine_GasAdvanced(String aName) { + super(aName); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[]{MACHINE_CASINGS[1][aColorIndex + 1], + aFacing == aSide ? + (aActive ? TextureFactory.builder().addIcon(LARGETURBINE_ADVGAS_ACTIVE5).extFacing().build() : hasTurbine() ? TextureFactory.builder().addIcon(LARGETURBINE_ADVGAS5).extFacing().build() : TextureFactory.builder().addIcon(LARGETURBINE_ADVGAS_EMPTY5).extFacing().build()) + : casingTexturePages[1][57]}; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Gas Turbine") + .addInfo("Controller block for the Large Advanced Gas Turbine") + .addInfo("Needs a Turbine, place inside controller") + .addInfo("Only accepts gases above 800k EU/bucket") + .addInfo("Has no maximum EU/t output, only depends on the Dynamo Hatch") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 4, true) + .addController("Front center") + .addCasingInfo("Advanced Gas Turbine Casing", 24) + .addDynamoHatch("Back center", 1) + .addMaintenanceHatch("Side centered", 2) + .addMufflerHatch("Side centered", 2) + .addInputHatch("Gas Fuel, Side centered", 2) + .toolTipFinisher("Gregtech"); + return tt; + } + + public int getFuelValue(FluidStack aLiquid) { + if (aLiquid == null) return 0; + GT_Recipe tFuel = GT_Recipe_Map.sTurbineFuels.findFuel(aLiquid); + if (tFuel != null) return tFuel.mSpecialValue; + return 0; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_LargeTurbine_GasAdvanced(mName); + } + + @Override + public Block getCasingBlock() { + return GregTech_API.sBlockCasings8; + } + + @Override + public byte getCasingMeta() { + return 9; + } + + @Override + public int getCasingTextureIndex() { return 185; } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return GT_Mod.gregtechproxy.mPollutionLargeGasTurbinePerSecond; + } + + @Override + int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff, int overflowMultiplier) { + if (aFluids.size() >= 1) { + 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! + int fuelValue = getFuelValue(firstFuelType); + + if (fuelValue < 800) { + return 0; + } + + if (aOptFlow < 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 GT_Utility.safeInt((long) aOptFlow * (long) aBaseEff / 10000L); + } + + actualOptimalFlow = GT_Utility.safeInt((long) aOptFlow / fuelValue); + this.realOptFlow = actualOptimalFlow; + + // Allowed to use up to 450% optimal flow rate, depending on the value of overflowMultiplier. + // This value is chosen because the highest EU/t possible depends on the overflowMultiplier, and the formula used + // makes it so the flow rate for that max, per value of overflowMultiplier, is (percentage of optimal flow rate): + // - 150% if it is 1 + // - 300% if it is 2 + // - 450% if it is 3 + // Variable required outside of loop for multi-hatch scenarios. + int remainingFlow = GT_Utility.safeInt((long) (actualOptimalFlow * (1.5f * overflowMultiplier))); + int flow = 0; + int totalFlow = 0; + + storedFluid = 0; + for (FluidStack aFluid : aFluids) { + if (aFluid.isFluidEqual(firstFuelType)) { + flow = Math.min(aFluid.amount, remainingFlow); // try to use up to the max flow defined just above + depleteInput(new FluidStack(aFluid, flow)); // deplete that amount + this.storedFluid += aFluid.amount; + remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches + totalFlow += flow; // track total input used + } + } + if (totalFlow <= 0) return 0; + tEU = GT_Utility.safeInt((long) totalFlow * fuelValue); + + if (totalFlow == actualOptimalFlow) { + tEU = GT_Utility.safeInt((long) tEU * (long) aBaseEff / 10000L); + } else { + float efficiency = getOverflowEfficiency(totalFlow, actualOptimalFlow, overflowMultiplier); + tEU *= efficiency; + tEU = GT_Utility.safeInt((long) tEU * (long) aBaseEff / 10000L); + } + + // If next output is above the maximum the dynamo can handle, set it to the maximum instead of exploding the turbine + // Raising the maximum allowed flow rate to account for the efficiency changes beyond the optimal flow + // When the max fuel consumption rate was increased, turbines could explode on world load + if (tEU > getMaximumOutput()){ + tEU = GT_Utility.safeInt(getMaximumOutput()); + } + return tEU; + + } + return 0; + } + + @Override + float getOverflowEfficiency(int totalFlow, int actualOptimalFlow, int overflowMultiplier) { + // overflowMultiplier changes how quickly the turbine loses efficiency after flow goes beyond the optimal value + // At the default value of 1, any flow will generate less EU/t than optimal flow, regardless of the amount of fuel used + // The bigger this number is, the slower efficiency loss happens as flow moves beyond the optimal value + // Gases are the second most efficient in this regard, with plasma being the most efficient + float efficiency = 0; + + if (totalFlow > actualOptimalFlow) { + efficiency = 1.0f - Math.abs((totalFlow - actualOptimalFlow)) / ((float) actualOptimalFlow * ((overflowMultiplier * 3) - 1)); + } + else { + efficiency = 1.0f - Math.abs((totalFlow - actualOptimalFlow) / (float) actualOptimalFlow); + } + + return efficiency; + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java index ab7c08513f..587ecebd2e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java @@ -79,7 +79,7 @@ public class GT_MetaTileEntity_LargeTurbine_HPSteam extends GT_MetaTileEntity_La } @Override - public byte getCasingTextureIndex() { + public int getCasingTextureIndex() { return 59; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java index 17cba19242..a99f1d4909 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java @@ -84,7 +84,7 @@ public class GT_MetaTileEntity_LargeTurbine_Plasma extends GT_MetaTileEntity_Lar } @Override - public byte getCasingTextureIndex() { + public int getCasingTextureIndex() { return 60; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java index bf9f3bfdbf..99da4006da 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java @@ -81,7 +81,7 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg } @Override - public byte getCasingTextureIndex() { + public int getCasingTextureIndex() { return 16; } |