diff options
author | Glease <4586901+Glease@users.noreply.github.com> | 2022-12-19 20:09:45 +0800 |
---|---|---|
committer | Glease <4586901+Glease@users.noreply.github.com> | 2022-12-20 22:24:48 +0800 |
commit | c940d737156a805a8406d8aaa9362dc6d82fec39 (patch) | |
tree | 271ac0840212cb588b16575a5694f50c2d395807 /src | |
parent | 209ff94f083b367fe01cfae8f2b12ecb93091ef4 (diff) | |
download | GT5-Unofficial-c940d737156a805a8406d8aaa9362dc6d82fec39.tar.gz GT5-Unofficial-c940d737156a805a8406d8aaa9362dc6d82fec39.tar.bz2 GT5-Unofficial-c940d737156a805a8406d8aaa9362dc6d82fec39.zip |
use advertised throughput instead of actual throughput
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java | 3 | ||||
-rw-r--r-- | src/main/java/net/glease/ggfab/util/LaserHelper.java | 45 |
2 files changed, 47 insertions, 1 deletions
diff --git a/src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java b/src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java index 851f9ba59c..4c8f7a7946 100644 --- a/src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java +++ b/src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java @@ -17,6 +17,7 @@ import gregtech.api.util.*; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import net.glease.ggfab.GGConstants; +import net.glease.ggfab.util.LaserHelper; import net.glease.ggfab.util.OverclockHelper; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayerMP; @@ -383,7 +384,7 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas private void recordEnergySupplier(GT_MetaTileEntity_Hatch hatch) { if (!isValidMetaTileEntity(hatch)) return; - inputEUt += hatch.maxEUInput() * hatch.maxAmperesIn(); + inputEUt += hatch.maxEUInput() * LaserHelper.getAmperes(hatch); inputVoltage = Math.min(inputVoltage, hatch.maxEUInput()); if (inputEUt < 0) // I'd prefer bullying colen than use bigint diff --git a/src/main/java/net/glease/ggfab/util/LaserHelper.java b/src/main/java/net/glease/ggfab/util/LaserHelper.java new file mode 100644 index 0000000000..53bf328eb7 --- /dev/null +++ b/src/main/java/net/glease/ggfab/util/LaserHelper.java @@ -0,0 +1,45 @@ +package net.glease.ggfab.util; + +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; + +import java.lang.reflect.Field; + +public class LaserHelper { + private static final Class<?> GT_MetaTileEntity_Hatch_EnergyMulti; + private static final Field fieldAmperes; + + static { + Class<?> tmp1; + Field tmp2; + try { + tmp1 = Class.forName("com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti"); + } catch (ClassNotFoundException e) { + tmp1 = null; + } + if (tmp1 != null) { + try { + tmp2 = tmp1.getField("Amperes"); + tmp2.setAccessible(true); + } catch (ReflectiveOperationException e) { + tmp1 = null; + tmp2 = null; + } + } else { + tmp2 = null; + } + GT_MetaTileEntity_Hatch_EnergyMulti = tmp1; + fieldAmperes = tmp2; + } + + public static long getAmperes(GT_MetaTileEntity_Hatch hatch) { + if (GT_MetaTileEntity_Hatch_EnergyMulti.isInstance(hatch)) { + try { + // target field is int, not long + return (int) fieldAmperes.get(hatch); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + return hatch.maxAmperesIn(); + } +} |