diff options
author | Alkalus <Draknyte1@hotmail.com> | 2020-05-30 21:31:52 +0100 |
---|---|---|
committer | Alkalus <Draknyte1@hotmail.com> | 2020-05-30 21:31:52 +0100 |
commit | 4ded21b4e901630a72fe2ccf7fd8dff56e744bb7 (patch) | |
tree | 99a8351468e1bf62fa8ee32f159b5c446c1c670a /src/Java/gtPlusPlus/xmod/gregtech | |
parent | 664c388b944e87125a9305fbbdda6a374854e0b5 (diff) | |
download | GT5-Unofficial-4ded21b4e901630a72fe2ccf7fd8dff56e744bb7.tar.gz GT5-Unofficial-4ded21b4e901630a72fe2ccf7fd8dff56e744bb7.tar.bz2 GT5-Unofficial-4ded21b4e901630a72fe2ccf7fd8dff56e744bb7.zip |
$ Fixed minor oversight in RC ASM.
$ Fixed bug where PSS would generate power due to an integer overflow.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech')
-rw-r--r-- | src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java index 3eabcf517e..6619bc1253 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java @@ -19,6 +19,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.NBTUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.preloader.asm.AsmConfig; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_PowerSubStation; @@ -36,7 +37,7 @@ import net.minecraftforge.common.util.ForgeDirection; public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMeta_MultiBlockBase { - protected int mAverageEuUsage = 0; + protected long mAverageEuUsage = 0; protected long mTotalEnergyAdded = 0; protected long mTotalEnergyConsumed = 0; protected long mTotalEnergyLost = 0; @@ -366,7 +367,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe //mTotalEnergyAdded @Override public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mAverageEuUsage", this.mAverageEuUsage); + aNBT.setLong("mAverageEuUsage", this.mAverageEuUsage); //Usage Stats aNBT.setLong("mTotalEnergyAdded", this.mTotalEnergyAdded); @@ -380,7 +381,17 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe @Override public void loadNBTData(NBTTagCompound aNBT) { - this.mAverageEuUsage = aNBT.getInteger("mAverageEuUsage"); + + // Best not to get a long if the Tag Map is holding an int + if (aNBT.hasKey("mAverageEuUsage")) { + if (NBTUtils.isTagInteger(aNBT, "mAverageEuUsage")) { + int aAverageTag = aNBT.getInteger("mAverageEuUsage"); + this.mAverageEuUsage = aAverageTag; + } + else { + this.mAverageEuUsage = aNBT.getLong("mAverageEuUsage"); + } + } //Usage Stats this.mTotalEnergyAdded = aNBT.getLong("mTotalEnergyAdded"); @@ -421,7 +432,9 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe long stored = aHatch.getEUVar(); long voltage = aHatch.maxEUInput() * aHatch.maxAmperesIn(); - if (voltage > stored) return; + if (voltage > stored) { + return; + } if (this.getBaseMetaTileEntity().increaseStoredEnergyUnits(voltage, false)) { aHatch.setEUVar((stored - voltage)); @@ -449,7 +462,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe // Increase tax up to 2x if machine is not fully repaired mTax = mTax * (1f + (10000f - mEfficiency) / 10000f); - return MathUtils.roundToClosestInt(mTax); + return MathUtils.roundToClosestLong(mTax); } |