parent
b82df25c75
commit
a725779ff6
1 changed files with 3 additions and 14 deletions
|
@ -85,21 +85,10 @@ class PoweredItemCapabilities implements ICapabilityProvider, IEnergyStorage
|
||||||
@Override
|
@Override
|
||||||
public int receiveEnergy( int maxReceive, boolean simulate )
|
public int receiveEnergy( int maxReceive, boolean simulate )
|
||||||
{
|
{
|
||||||
if( simulate )
|
final double convertedOffer = PowerUnits.RF.convertTo( PowerUnits.AE, maxReceive );
|
||||||
{
|
final double overflow = this.item.injectAEPower( this.is, convertedOffer, simulate ? Actionable.SIMULATE : Actionable.MODULATE );
|
||||||
final int required = (int) PowerUnits.AE.convertTo( PowerUnits.RF, this.item.getAEMaxPower( this.is ) - this.item.getAECurrentPower( this.is ) );
|
|
||||||
|
|
||||||
if( maxReceive < required )
|
return maxReceive - (int) PowerUnits.AE.convertTo( PowerUnits.RF, overflow );
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return maxReceive - required;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
final double powerRemainder = this.item.injectAEPower( this.is, PowerUnits.RF.convertTo( PowerUnits.AE, maxReceive ), Actionable.MODULATE );
|
|
||||||
return maxReceive - (int) PowerUnits.AE.convertTo( PowerUnits.RF, powerRemainder );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue