From 65986ca1419944e1cf14cd39683dd9d723ac6993 Mon Sep 17 00:00:00 2001 From: Maxim Date: Sat, 14 Jan 2023 20:34:15 +0100 Subject: Added getter for average voltage (#1653) --- .../java/gregtech/api/util/GT_ExoticEnergyInputHelper.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api/util') diff --git a/src/main/java/gregtech/api/util/GT_ExoticEnergyInputHelper.java b/src/main/java/gregtech/api/util/GT_ExoticEnergyInputHelper.java index 8fbb79faff..820ec07487 100644 --- a/src/main/java/gregtech/api/util/GT_ExoticEnergyInputHelper.java +++ b/src/main/java/gregtech/api/util/GT_ExoticEnergyInputHelper.java @@ -58,7 +58,7 @@ public class GT_ExoticEnergyInputHelper { } public static long getTotalEuMulti(Collection hatches) { - return getMaxWorkingInputAmpsMulti(hatches) * getMaxInputVoltageMulti(hatches); + return getMaxWorkingInputAmpsMulti(hatches) * getAverageInputVoltageMulti(hatches); } public static long getMaxInputVoltageMulti(Collection hatches) { @@ -69,6 +69,17 @@ public class GT_ExoticEnergyInputHelper { return rVoltage; } + public static long getAverageInputVoltageMulti(Collection hatches) { + long rVoltage = 0; + if (hatches.size() <= 0) { + return rVoltage; + } + for (GT_MetaTileEntity_Hatch tHatch : hatches) + if (isValidMetaTileEntity(tHatch)) + rVoltage += tHatch.getBaseMetaTileEntity().getInputVoltage(); + return rVoltage / hatches.size(); + } + public static long getMaxInputAmpsMulti(Collection hatches) { long rAmp = 0; for (GT_MetaTileEntity_Hatch tHatch : hatches) -- cgit