diff options
author | Abdiel Kavash <19243993+AbdielKavash@users.noreply.github.com> | 2024-11-20 11:08:11 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-20 18:08:11 +0100 |
commit | 36acbb9baed7dae4e19fde7a95852b7d002b2f5c (patch) | |
tree | 373ef20415a65c444a214a5398b6c550cfc2b5df /src/main/java/gtPlusPlus/xmod | |
parent | 4ecb0005608fb5774dee56eb751c850d862fa98d (diff) | |
download | GT5-Unofficial-36acbb9baed7dae4e19fde7a95852b7d002b2f5c.tar.gz GT5-Unofficial-36acbb9baed7dae4e19fde7a95852b7d002b2f5c.tar.bz2 GT5-Unofficial-36acbb9baed7dae4e19fde7a95852b7d002b2f5c.zip |
Follow up fixes for multiple muffler hatches. (#3505)
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod')
3 files changed, 13 insertions, 32 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchMufflerAdvanced.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchMufflerAdvanced.java index 5919a71b25..40e804bf36 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchMufflerAdvanced.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchMufflerAdvanced.java @@ -84,18 +84,21 @@ public class MTEHatchMufflerAdvanced extends MTEHatchMuffler implements IAddGreg } @Override - public boolean polluteEnvironment(MetaTileEntity parentTileEntity) { + public boolean polluteEnvironment(MetaTileEntity parentTileEntity, int pollutionAmount) { if (!airCheck()) return false; // Muffler obstructed. - - int emission = 10000; - if (damageAirFilter(parentTileEntity)) { + if (pollutionAmount < 10000 && pollutionAmount <= parentTileEntity.getBaseMetaTileEntity() + .getRandomNumber(10000)) { + // If we are venting less than the maximum amount of pollution, damage filter with a lower chance. + // This happens if a multiblock has more than one muffler. + pollutionAmount = calculatePollutionReduction(pollutionAmount, true); + } else if (damageAirFilter(parentTileEntity)) { // damageAirFilter already checks that we have a valid filter. - emission = calculatePollutionReduction(emission, true); + pollutionAmount = calculatePollutionReduction(pollutionAmount, true); } else { // Revert to reduction of the basic muffler. - emission = super.calculatePollutionReduction(emission); + pollutionAmount = super.calculatePollutionReduction(pollutionAmount); } - Pollution.addPollution(getBaseMetaTileEntity(), emission); + Pollution.addPollution(getBaseMetaTileEntity(), pollutionAmount); return true; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GTPPMultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GTPPMultiBlockBase.java index df55649bb5..9b5448ac49 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GTPPMultiBlockBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GTPPMultiBlockBase.java @@ -240,7 +240,6 @@ public abstract class GTPPMultiBlockBase<T extends MTEExtendedPowerMultiBlockBas + " %"); if (this.getPollutionPerSecond(null) > 0) { - int mPollutionReduction = getPollutionReductionForAllMufflers(); mInfo.add( StatCollector.translateToLocal("GTPP.multiblock.pollution") + ": " + EnumChatFormatting.RED @@ -250,7 +249,7 @@ public abstract class GTPPMultiBlockBase<T extends MTEExtendedPowerMultiBlockBas mInfo.add( StatCollector.translateToLocal("GTPP.multiblock.pollutionreduced") + ": " + EnumChatFormatting.GREEN - + mPollutionReduction + + getAveragePollutionPercentage() + EnumChatFormatting.RESET + " %"); } @@ -287,14 +286,6 @@ public abstract class GTPPMultiBlockBase<T extends MTEExtendedPowerMultiBlockBas return mInfo.toArray(new String[0]); } - public int getPollutionReductionForAllMufflers() { - int mPollutionReduction = 0; - for (MTEHatchMuffler tHatch : validMTEList(mMufflerHatches)) { - mPollutionReduction = Math.max(calculatePollutionReductionForHatch(tHatch, 100), mPollutionReduction); - } - return mPollutionReduction; - } - public long getStoredEnergyInAllEnergyHatches() { long storedEnergy = 0; for (MTEHatch tHatch : validMTEList(mAllEnergyHatches)) { @@ -1404,7 +1395,7 @@ public abstract class GTPPMultiBlockBase<T extends MTEExtendedPowerMultiBlockBas .dynamicString( () -> StatCollector.translateToLocal("GTPP.multiblock.pollutionreduced") + ": " + EnumChatFormatting.GREEN - + getPollutionReductionForAllMufflers() + + getAveragePollutionPercentage() + EnumChatFormatting.RESET + " %") .setDefaultColor(COLOR_TEXT_WHITE.get()) 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 1623346299..e96493351e 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 @@ -41,7 +41,6 @@ import gregtech.api.items.MetaGeneratedTool; import gregtech.api.metatileentity.implementations.MTEHatch; import gregtech.api.metatileentity.implementations.MTEHatchDynamo; import gregtech.api.metatileentity.implementations.MTEHatchInputBus; -import gregtech.api.metatileentity.implementations.MTEHatchMuffler; import gregtech.api.recipe.check.CheckRecipeResult; import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GTUtility; @@ -120,7 +119,6 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase<MTELargerT protected int storedFluid = 0; protected int counter = 0; protected boolean looseFit = false; - protected double mufflerReduction = 1; protected float[] flowMultipliers = new float[] { 1, 1, 1 }; public ITexture frontFace = new GTPPRenderedTexture(TexturesGtBlock.Overlay_Machine_Controller_Advanced); @@ -188,14 +186,6 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase<MTELargerT return getPollutionPerSecond(null) > 0; } - public final double getMufflerReduction() { - double totalReduction = 0; - for (MTEHatchMuffler tHatch : validMTEList(mMufflerHatches)) { - totalReduction += ((double) tHatch.calculatePollutionReduction(100)) / 100; - } - return totalReduction / 4; - } - @Override public void clearHatches() { super.clearHatches(); @@ -229,7 +219,6 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase<MTELargerT + mOutputHatches.size()); return false; } - mufflerReduction = getMufflerReduction(); return aStructure; } @@ -559,8 +548,6 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase<MTELargerT @Override public String[] getExtraInfoData() { - int mPollutionReduction = (int) (100 * mufflerReduction); - String tRunning = mMaxProgresstime > 0 ? EnumChatFormatting.GREEN + StatCollector.translateToLocal("GT5U.turbine.running.true") + EnumChatFormatting.RESET @@ -640,7 +627,7 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase<MTELargerT StatCollector.translateToLocal("GT5U.turbine.dmg") + ": " + aTurbineDamage, StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + EnumChatFormatting.GREEN - + GTUtility.formatNumbers(mPollutionReduction) + + getAveragePollutionPercentage() + EnumChatFormatting.RESET + " %" }; } |