public IBatteryObject provider(final TileEntity te, final ForgeDirection side)
{
if ( te instanceof IPowerReceptor )
{
final IPowerReceptor receptor = (IPowerReceptor) te;
final PowerReceiver ph = receptor.getPowerReceiver( side );
if ( ph == null )
return null;
return new IBatteryObject() {
@Override
public void setEnergyStored(double mj)
{
}
@Override
public IBatteryObject reconfigure(double maxCapacity, double maxReceivedPerCycle, double minimumConsumption)
{
return this;
}
@Override
public double minimumConsumption()
{
return ph.getMinEnergyReceived();
}
@Override
public double maxReceivedPerCycle()
{
return ph.getMaxEnergyReceived();
}
@Override
public double maxCapacity()
{
return ph.getMaxEnergyStored();
}
@Override
public String kind()
{
return MjAPI.DEFAULT_POWER_FRAMEWORK;
}
@Override
public double getEnergyStored()
{
return ph.getEnergyStored();
}
@Override
public double getEnergyRequested()
{
return ph.getMaxEnergyStored() - ph.getEnergyStored();
}
@Override
public double addEnergy(double mj, boolean ignoreCycleLimit)
{
return ph.receiveEnergy( Type.PIPE, mj, side );
}
@Override
public double addEnergy(double mj)
{
return ph.receiveEnergy( Type.PIPE, mj, side );
}
};
}
return null;
}