diff options
author | Jordan Byrne <draknyte1@hotmail.com> | 2018-01-24 18:38:51 +1000 |
---|---|---|
committer | Jordan Byrne <draknyte1@hotmail.com> | 2018-01-24 18:38:51 +1000 |
commit | 7ddb7f5e8ed9fe60b730183c7a04f3bce3b8f815 (patch) | |
tree | 735ad1d98be4b7ec4469df6bec8370ee4f503e03 /src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity | |
parent | f357e3a1753c7c542d48bb217d8a2545cb9544c4 (diff) | |
download | GT5-Unofficial-7ddb7f5e8ed9fe60b730183c7a04f3bce3b8f815.tar.gz GT5-Unofficial-7ddb7f5e8ed9fe60b730183c7a04f3bce3b8f815.tar.bz2 GT5-Unofficial-7ddb7f5e8ed9fe60b730183c7a04f3bce3b8f815.zip |
$ Several 5.08 compat fixes.
$ Fixed pollution, which was causing all multiblocks to fail. This was pointed out in #191 by @CodeWarrior0, however I decided to re-do it myself to better handle the .08 compat.
$ Fixed all multiblocks being broken as fuck. Fixes #190, fixes #186 and also fixes #176.
- Removed some useless logging from the mining explosives.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity')
-rw-r--r-- | src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index f6a8d55174..79f5b22840 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -16,7 +16,9 @@ import gregtech.api.util.GT_Recipe; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.PollutionUtils; import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_MultiMachine; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBattery; @@ -420,23 +422,35 @@ GT_MetaTileEntity_MultiBlockBase { } public boolean polluteEnvironment(int aPollutionLevel) { - int mPollution = 0; - Field f = FieldUtils.getDeclaredField(this.getClass(), "mPollution", true); + try { + Integer mPollution = 0; + Field f = ReflectionUtils.getField(this.getClass(), "mPollution"); if (f != null){ + Logger.REFLECTION("pollution field was not null"); try { - mPollution = (int) f.get(this); + mPollution = (Integer) f.get(this); + if (mPollution != null){ + Logger.REFLECTION("pollution field value was not null"); + } + else { + Logger.REFLECTION("pollution field value was null"); + } } catch (IllegalArgumentException | IllegalAccessException e) {} } + else { + Logger.REFLECTION("pollution field was null"); + } if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && f != null){ + Logger.REFLECTION("doing pollution"); mPollution += aPollutionLevel; for (final GT_MetaTileEntity_Hatch_Muffler tHatch : this.mMufflerHatches) { if (isValidMetaTileEntity(tHatch)) { if (mPollution < 10000) { break; } - if (!tHatch.polluteEnvironment()) { + if (!polluteEnvironmentHatch(tHatch)) { continue; } mPollution -= 10000; @@ -447,7 +461,25 @@ GT_MetaTileEntity_MultiBlockBase { else { return false; } - + } + catch (Throwable t){ + Logger.REFLECTION("Failed to add pollution."); + t.printStackTrace(); + return false; + } + } + + public boolean polluteEnvironmentHatch(GT_MetaTileEntity_Hatch_Muffler tHatch) { + if (tHatch.getBaseMetaTileEntity().getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing())) { + PollutionUtils.addPollution(tHatch.getBaseMetaTileEntity(), calculatePollutionReduction(tHatch, 10000)); + return true; + } else { + return false; + } + } + + public int calculatePollutionReduction(GT_MetaTileEntity_Hatch_Muffler tHatch, int aPollution) { + return (int) ((double) aPollution * Math.pow(0.7D, (double) (tHatch.mTier - 1))); } } |