From 9d091aa47ee71ddd6dc21b387bbd865fd54fcc4f Mon Sep 17 00:00:00 2001 From: Yang Xizhi <60341015+GlodBlock@users.noreply.github.com> Date: Mon, 20 Dec 2021 02:02:09 +0800 Subject: fix energy drain logic (#72) fix https://github.com/GTNewHorizons/Dupes-Exploits-GTNH/issues/19 Former-commit-id: c6803ac0d09a412e6afcb8f41a09888321d759fa --- .../bartimaeusnek/crossmod/tectech/helper/TecTechUtils.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/helper/TecTechUtils.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/helper/TecTechUtils.java index bc28090155..735b7dbe53 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/helper/TecTechUtils.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/helper/TecTechUtils.java @@ -79,18 +79,20 @@ public class TecTechUtils { if (allTheEu < aEU) return false; + if (hatches == 0) return false; + long euperhatch = aEU / hatches; - boolean hasDrained = false; + boolean hasDrained = true; for (GT_MetaTileEntity_Hatch_Energy tHatch : multi.getVanillaEnergyHatches()) - hasDrained |= tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euperhatch, false); + hasDrained &= tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euperhatch, false); for (GT_MetaTileEntity_Hatch_EnergyTunnel tHatch : multi.getTecTechEnergyTunnels()) - hasDrained |= tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euperhatch, false); + hasDrained &= tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euperhatch, false); for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : multi.getTecTechEnergyMultis()) - hasDrained |= tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euperhatch, false); + hasDrained &= tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euperhatch, false); return hasDrained && (multi.getVanillaEnergyHatches().size() > 0 || multi.getTecTechEnergyTunnels().size() > 0 || multi.getTecTechEnergyMultis().size() > 0); } @@ -146,4 +148,4 @@ public class TecTechUtils { public static long getEUPerTickFromLaser(GT_MetaTileEntity_Hatch_EnergyTunnel tHatch) { return tHatch.Amperes * tHatch.maxEUInput() - (tHatch.Amperes / 20); } -} \ No newline at end of file +} -- cgit