aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbinePlasma.java
diff options
context:
space:
mode:
authorNotAPenguin <michiel.vandeginste@gmail.com>2024-09-02 23:17:17 +0200
committerGitHub <noreply@github.com>2024-09-02 23:17:17 +0200
commit1b820de08a05070909a267e17f033fcf58ac8710 (patch)
tree02831a025986a06b20f87e5bcc69d1e0c639a342 /src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbinePlasma.java
parentafd3fd92b6a6ab9ab0d0dc3214e6bc8ff7a86c9b (diff)
downloadGT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.tar.gz
GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.tar.bz2
GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.zip
The Great Renaming (#3014)
* move kekztech to a single root dir * move detrav to a single root dir * move gtnh-lanthanides to a single root dir * move tectech and delete some gross reflection in gt++ * remove more reflection inside gt5u * delete more reflection in gt++ * fix imports * move bartworks and bwcrossmod * fix proxies * move galactigreg and ggfab * move gtneioreplugin * try to fix gt++ bee loader * apply the rename rules to BW * apply rename rules to bwcrossmod * apply rename rules to detrav scanner mod * apply rename rules to galacticgreg * apply rename rules to ggfab * apply rename rules to goodgenerator * apply rename rules to gtnh-lanthanides * apply rename rules to gt++ * apply rename rules to kekztech * apply rename rules to kubatech * apply rename rules to tectech * apply rename rules to gt apply the rename rules to gt * fix tt import * fix mui hopefully * fix coremod except intergalactic * rename assline recipe class * fix a class name i stumbled on * rename StructureUtility to GTStructureUtility to prevent conflict with structurelib * temporary rename of GTTooltipDataCache to old name * fix gt client/server proxy names
Diffstat (limited to 'src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbinePlasma.java')
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbinePlasma.java389
1 files changed, 389 insertions, 0 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbinePlasma.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbinePlasma.java
new file mode 100644
index 0000000000..667d52a4cd
--- /dev/null
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbinePlasma.java
@@ -0,0 +1,389 @@
+package gregtech.common.tileentities.machines.multi;
+
+import static gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_NEW5;
+import static gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_NEW_ACTIVE5;
+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.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;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+
+import org.jetbrains.annotations.NotNull;
+
+import gregtech.api.GregTechAPI;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.items.MetaGeneratedTool;
+import gregtech.api.metatileentity.implementations.MTEHatchDynamo;
+import gregtech.api.metatileentity.implementations.MTEHatchMuffler;
+import gregtech.api.recipe.RecipeMap;
+import gregtech.api.recipe.RecipeMaps;
+import gregtech.api.recipe.check.CheckRecipeResult;
+import gregtech.api.recipe.check.CheckRecipeResultRegistry;
+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.common.items.MetaGeneratedTool01;
+
+public class MTELargeTurbinePlasma extends MTELargeTurbine {
+
+ public MTELargeTurbinePlasma(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+ }
+
+ public MTELargeTurbinePlasma(String aName) {
+ super(aName);
+ }
+
+ @Override
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing,
+ int colorIndex, boolean aActive, boolean redstoneLevel) {
+ return new ITexture[] { MACHINE_CASINGS[1][colorIndex + 1],
+ aFacing == side ? (aActive ? TextureFactory.builder()
+ .addIcon(LARGETURBINE_NEW_ACTIVE5)
+ .build()
+ : hasTurbine() ? TextureFactory.builder()
+ .addIcon(LARGETURBINE_NEW5)
+ .build()
+ : TextureFactory.builder()
+ .addIcon(LARGETURBINE_NEW_EMPTY5)
+ .build())
+ : casingTexturePages[0][60] };
+ }
+
+ @Override
+ protected MultiblockTooltipBuilder createTooltip() {
+ final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder();
+ tt.addMachineType("Plasma Turbine")
+ .addInfo("Controller block for the Large Plasma Generator")
+ .addInfo("Needs a Turbine, place inside controller")
+ .addInfo("Use your Fusion Reactor to produce the Plasma")
+ .addSeparator()
+ .beginStructureBlock(3, 3, 4, true)
+ .addController("Front center")
+ .addCasingInfoRange("Tungstensteel Turbine Casing", 8, 31, false)
+ .addDynamoHatch("Back center", 1)
+ .addMaintenanceHatch("Side centered", 2)
+ .addInputHatch("Plasma Fluid, Side centered", 2)
+ .addOutputHatch("Molten Fluid, optional, Side centered", 2)
+ .toolTipFinisher("Gregtech");
+ return tt;
+ }
+
+ public int getFuelValue(FluidStack aLiquid) {
+ if (aLiquid == null) return 0;
+ GTRecipe tFuel = RecipeMaps.plasmaFuels.getBackend()
+ .findFuel(aLiquid);
+ if (tFuel != null) return tFuel.mSpecialValue;
+ return 0;
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new MTELargeTurbinePlasma(mName);
+ }
+
+ @Override
+ public RecipeMap<?> getRecipeMap() {
+ return RecipeMaps.plasmaFuels;
+ }
+
+ @Override
+ public int getRecipeCatalystPriority() {
+ return -1;
+ }
+
+ @Override
+ protected boolean filtersFluid() {
+ return false;
+ }
+
+ @Override
+ public Block getCasingBlock() {
+ return GregTechAPI.sBlockCasings4;
+ }
+
+ @Override
+ public byte getCasingMeta() {
+ return 12;
+ }
+
+ @Override
+ public int getCasingTextureIndex() {
+ return 60;
+ }
+
+ @Override
+ public boolean isNewStyleRendering() {
+ return true;
+ }
+
+ @Override
+ int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff, int overflowMultiplier,
+ float[] flowMultipliers) {
+ 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!
+ int fuelValue = getFuelValue(firstFuelType);
+ actualOptimalFlow = GTUtility
+ .safeInt((long) Math.ceil((double) aOptFlow * flowMultipliers[2] / (double) fuelValue));
+ this.realOptFlow = actualOptimalFlow; // For scanner info
+
+ // Allowed to use up to 550% 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):
+ // - 250% if it is 1
+ // - 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 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
+ }
+ }
+ String fn = FluidRegistry.getFluidName(firstFuelType);
+ String[] nameSegments = fn.split("\\.", 2);
+ if (nameSegments.length == 2) {
+ String outputName = nameSegments[1];
+ FluidStack output = FluidRegistry.getFluidStack(outputName, totalFlow);
+ if (output == null) {
+ output = FluidRegistry.getFluidStack("molten." + outputName, totalFlow);
+ }
+ if (output != null) {
+ addOutput(output);
+ }
+ }
+ if (totalFlow <= 0) return 0;
+ tEU = GTUtility.safeInt((long) ((fuelValue / 20D) * (double) totalFlow));
+
+ // GT_FML_LOGGER.info(totalFlow+" : "+fuelValue+" : "+aOptFlow+" : "+actualOptimalFlow+" : "+tEU);
+
+ if (totalFlow != actualOptimalFlow) {
+ float efficiency = getOverflowEfficiency(totalFlow, actualOptimalFlow, overflowMultiplier);
+ tEU = (int) (tEU * efficiency);
+ }
+ tEU = GTUtility.safeInt((long) (aBaseEff / 10000D * tEU));
+
+ // 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
+ if (tEU > getMaximumOutput()) {
+ tEU = GTUtility.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
+ // Plasmas are the most efficient out of all turbine fuels in this regard
+ 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;
+ }
+
+ @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 {
+ 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;
+ }
+ }
+
+ @Override
+ public String[] getInfoData() {
+ int mPollutionReduction = 0;
+ for (MTEHatchMuffler tHatch : filterValidMTEs(mMufflerHatches)) {
+ mPollutionReduction = Math.max(tHatch.calculatePollutionReduction(100), mPollutionReduction);
+ }
+
+ String tRunning = mMaxProgresstime > 0
+ ? EnumChatFormatting.GREEN + StatCollector.translateToLocal("GT5U.turbine.running.true")
+ + EnumChatFormatting.RESET
+ : EnumChatFormatting.RED + StatCollector.translateToLocal("GT5U.turbine.running.false")
+ + EnumChatFormatting.RESET;
+ String tMaintainance = getIdealStatus() == getRepairStatus()
+ ? EnumChatFormatting.GREEN + StatCollector.translateToLocal("GT5U.turbine.maintenance.false")
+ + EnumChatFormatting.RESET
+ : EnumChatFormatting.RED + StatCollector.translateToLocal("GT5U.turbine.maintenance.true")
+ + EnumChatFormatting.RESET;
+ int tDura = 0;
+
+ if (mInventory[1] != null && mInventory[1].getItem() instanceof MetaGeneratedTool01) {
+ tDura = GTUtility.safeInt(
+ (long) (100.0f / MetaGeneratedTool.getToolMaxDamage(mInventory[1])
+ * (MetaGeneratedTool.getToolDamage(mInventory[1])) + 1));
+ }
+
+ long storedEnergy = 0;
+ long maxEnergy = 0;
+ for (MTEHatchDynamo tHatch : filterValidMTEs(mDynamoHatches)) {
+ storedEnergy += tHatch.getBaseMetaTileEntity()
+ .getStoredEU();
+ maxEnergy += tHatch.getBaseMetaTileEntity()
+ .getEUCapacity();
+ }
+ String[] ret = new String[] {
+ // 8 Lines available for information panels
+ tRunning + ": "
+ + EnumChatFormatting.RED
+ + GTUtility.formatNumbers(((long) mEUt * mEfficiency) / 10000)
+ + EnumChatFormatting.RESET
+ + " EU/t", /* 1 */
+ tMaintainance, /* 2 */
+ StatCollector.translateToLocal("GT5U.turbine.efficiency") + ": "
+ + EnumChatFormatting.YELLOW
+ + (mEfficiency / 100F)
+ + EnumChatFormatting.RESET
+ + "%", /* 2 */
+ StatCollector.translateToLocal("GT5U.multiblock.energy") + ": "
+ + EnumChatFormatting.GREEN
+ + GTUtility.formatNumbers(storedEnergy)
+ + EnumChatFormatting.RESET
+ + " EU / "
+ + /* 3 */ EnumChatFormatting.YELLOW
+ + GTUtility.formatNumbers(maxEnergy)
+ + EnumChatFormatting.RESET
+ + " EU",
+ StatCollector.translateToLocal("GT5U.turbine.flow") + ": "
+ + EnumChatFormatting.YELLOW
+ + GTUtility.formatNumbers(GTUtility.safeInt((long) realOptFlow))
+ + EnumChatFormatting.RESET
+ + " L/s"
+ + /* 4 */ EnumChatFormatting.YELLOW
+ + " ("
+ + (looseFit ? StatCollector.translateToLocal("GT5U.turbine.loose")
+ : StatCollector.translateToLocal("GT5U.turbine.tight"))
+ + ")", /* 5 */
+ StatCollector.translateToLocal("GT5U.turbine.fuel") + ": "
+ + EnumChatFormatting.GOLD
+ + GTUtility.formatNumbers(storedFluid)
+ + EnumChatFormatting.RESET
+ + "L", /* 6 */
+ StatCollector.translateToLocal(
+ "GT5U.turbine.dmg") + ": " + EnumChatFormatting.RED + tDura + EnumChatFormatting.RESET + "%", /* 7 */
+ StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": "
+ + EnumChatFormatting.GREEN
+ + mPollutionReduction
+ + EnumChatFormatting.RESET
+ + " %" /* 8 */
+ };
+ if (!this.getClass()
+ .getName()
+ .contains("Steam"))
+ ret[4] = StatCollector.translateToLocal("GT5U.turbine.flow") + ": "
+ + EnumChatFormatting.YELLOW
+ + GTUtility.safeInt((long) realOptFlow)
+ + EnumChatFormatting.RESET
+ + " L/s";
+ return ret;
+ }
+}