GregTechCEu Modern

GregTechCEu Modern

6M Downloads

Singleblock generators explode when fed power

Closed this issue ยท 2 comments

commented

Checked for existing issues

  • I have checked for existing issues, and have found none.

Tested latest version

  • I have checked that this occurs on the latest version.

GregTech CEu Version

7.1.0-SNAPSHOT+f51d89c

Minecraft Version

1.21.1 NeoForge

Recipe Viewer Installed

None

Environment

Singleplayer

Cross-Mod Interaction

Unsure

Other Installed Mods

(edit: I replicated this with only GTCEUM)

Expected Behavior

Putting more than one generator on the same cable shouldn't cause an explosion.

Actual Behavior

BOOM

Steps to Reproduce

  • Place 2 LV generators on the same LV cable line.
  • Put fuel in both generators.

You can also place them facing each other without a cable. Or place a single LV generator facing a battery buffer, with the buffer output pointing into the generator.

Additional Information

I think that while the generator is running, the output side is also acting as an input somehow.
It can be worked around by using diodes after each generator.

commented

It's exploding in NotifiableEnergyContainer acceptEnergyFromNetwork method.
I added some log lines:

    @Override
    public long acceptEnergyFromNetwork(Direction side, long voltage, long amperage) {
        var latestTimeStamp = getMachine().getOffsetTimer();
        if (lastTimeStamp < latestTimeStamp) {
            amps = 0;
            lastTimeStamp = latestTimeStamp;
        }
        if (amps >= getInputAmperage()) return 0;
        long canAccept = getEnergyCapacity() - getEnergyStored();
        if (voltage > 0L && (side == null || inputsEnergy(side))) {
            if (voltage > getInputVoltage() && machine instanceof IExplosionMachine explosionMachine) {
                GTCEu.LOGGER.error("[NotifiableEnergyContainer] Side = {}", side);
                GTCEu.LOGGER.error("[NotifiableEnergyContainer] Got voltage {}, max input voltage {}", voltage, getInputVoltage());
                explosionMachine.doExplosion(GTUtil.getExplosionPower(voltage));
                return Math.min(amperage, getInputAmperage() - amps);
            }
            if (canAccept >= voltage) {
                long amperesAccepted = Math.min(canAccept / voltage, Math.min(amperage, getInputAmperage() - amps));
                if (amperesAccepted > 0) {
                    setEnergyStored(getEnergyStored() + voltage * amperesAccepted);
                    amps += amperesAccepted;
                    return amperesAccepted;
                }
            }
        }
        return 0;
    }
[21:49:14] [Server thread/ERROR] [GTCEu/]: [NotifiableEnergyContainer] Side = null
[21:49:14] [Server thread/ERROR] [GTCEu/]: [NotifiableEnergyContainer] Got voltage 32, max input voltage 0

So it seems like the generator is trying to draw power from the EU network, and from a null side?

commented

This issue is specific to 1.21. In 1.20 the NotifiableEnergyContainer acceptEnergyFromNetwork method doesn't get called in this case.