diff --git a/src/main/java/tectech/loader/recipe/ResearchStationAssemblyLine.java b/src/main/java/tectech/loader/recipe/ResearchStationAssemblyLine.java index f20177950fe..e22f934b559 100644 --- a/src/main/java/tectech/loader/recipe/ResearchStationAssemblyLine.java +++ b/src/main/java/tectech/loader/recipe/ResearchStationAssemblyLine.java @@ -3525,10 +3525,8 @@ private void addWirelessEnergyRecipes() { for (int i = 0; i < wirelessLasers.length; i++) { TTRecipeAdder.addResearchableAssemblylineRecipe( - i != 8 ? laserTargets_UXV[i] : wirelessLasers[i - 1], // If current laser registered is UXV 4MA switch - // research item to avoid duplicate qc result from - // normal UXV 4MA laser, see this: - // https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/17188 + i != 7 ? laserTargets_UXV[i] : CustomItemList.eM_energyWirelessTunnel7_UXV.get(1), + // If current laser registered is UXV 4MA, switch research item to avoid research conflict totalComputation * 64, compPerSecond * 64, researchEuPerTick * 4, diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessMulti.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessMulti.java index 09d76c29a1c..6c737a7d2a4 100644 --- a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessMulti.java +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessMulti.java @@ -16,6 +16,8 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; +import com.google.common.math.LongMath; + import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IWirelessEnergyHatchInformation; @@ -25,9 +27,21 @@ public class MTEHatchWirelessMulti extends MTEHatchEnergyMulti implements IWirelessEnergyHatchInformation { - private final BigInteger eu_transferred_per_operation = BigInteger - .valueOf(Amperes * V[mTier] * ticks_between_energy_addition); - private final long eu_transferred_per_operation_long = eu_transferred_per_operation.longValue(); + private final long precisionMultiplier = LongMath.pow(10, 15); + private final BigInteger eu_transferred_per_operation = BigInteger.valueOf(Amperes * V[mTier]) + .multiply(BigInteger.valueOf(ticks_between_energy_addition)); + + private final double overflowDivisor = getOverflowDivisor(eu_transferred_per_operation); + + private final long actualTicksBetweenEnergyAddition = overflowDivisor > 1 + ? (long) (ticks_between_energy_addition / (overflowDivisor * 2)) + : ticks_between_energy_addition; + + private final long eu_transferred_per_operation_long = overflowDivisor > 1 + ? eu_transferred_per_operation.divide(BigInteger.valueOf((long) (overflowDivisor * precisionMultiplier * 2))) + .multiply(BigInteger.valueOf(precisionMultiplier)) + .longValue() + : eu_transferred_per_operation.longValue(); private UUID owner_uuid; @@ -49,6 +63,13 @@ public MTEHatchWirelessMulti(String aName, int aTier, int aAmp, String[] aDescri super(aName, aTier, aAmp, aDescription, aTextures); } + private double getOverflowDivisor(BigInteger euTransferredPerOperation) { + if (euTransferredPerOperation.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0) { + return euTransferredPerOperation.doubleValue() / Long.MAX_VALUE; + } + return 1d; + } + private ITexture[] TEXTURE_OVERLAY; @Override @@ -131,7 +152,7 @@ public long maxEUInput() { @Override public long maxEUStore() { - return totalStorage(V[mTier]) * Amperes / 2; + return (long) (totalStorage(V[mTier]) / (2 * overflowDivisor) * Amperes); } @Override @@ -191,8 +212,9 @@ public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { // network // it should make no difference to them. Minimising the number of operations on BigInteger is essential. - // Every ticks_between_energy_addition add eu_transferred_per_operation to internal EU storage from network. - if (aTick % ticks_between_energy_addition == 0L) { + // Every actualTicksBetweenEnergyAddition add eu_transferred_per_operation to internal EU storage from + // network. + if (aTick % actualTicksBetweenEnergyAddition == 0L) { tryFetchingEnergy(); } }