for (PartP2PBCPower o : tunnels)
{
IPowerReceptor target = o.getPowerTarget();
if ( target != null )
{
PowerReceiver tp = target.getPowerReceiver( side.getOpposite() );
if ( tp != null )
{
double request = tp.powerRequest();
if ( request > tp.getMaxEnergyReceived() )
request = tp.getMaxEnergyReceived();
if ( request > 0.01 && request > tp.getMinEnergyReceived() )
{
totalRequiredPower += request;
}
}
}
}
if ( totalRequiredPower < 0.1 )
return TickRateModulation.SLOWER;
double currentTotal = pp.getPowerReceiver().getEnergyStored();
if ( currentTotal < 0.01 )
return TickRateModulation.SLOWER;
for (PartP2PBCPower o : tunnels)
{
IPowerReceptor target = o.getPowerTarget();
if ( target != null )
{
PowerReceiver tp = target.getPowerReceiver( side.getOpposite() );
if ( tp != null )
{
double request = tp.powerRequest();
if ( request > tp.getMaxEnergyReceived() )
request = tp.getMaxEnergyReceived();
if ( request > 0.01 && request > tp.getMinEnergyReceived() )
{
double toPull = currentTotal * (request / totalRequiredPower);
double pulled = pp.useEnergy( 0, toPull, true );
QueueTunnelDrain( PowerUnits.MJ, pulled );
tp.receiveEnergy( Type.PIPE, pulled, o.side.getOpposite() );
}
}
}
}