Added item charging via legacy RF API.

This commit is contained in:
Sebastian Hartte
2016-11-06 22:22:49 +01:00
parent 9c8f914f42
commit 41a029ffb4
3 changed files with 84 additions and 1 deletions
@@ -146,6 +146,27 @@ public abstract class AERootPoweredItem extends AEBaseItem implements IAEItemPow
return currentStorage;
}
/**
* Inject power into this item using an external unit.
*/
double injectExternalPower( PowerUnits inputUnit, final ItemStack is, final double amount, final boolean simulate )
{
if( simulate )
{
final int requiredExt = (int) PowerUnits.AE.convertTo( inputUnit, this.getAEMaxPower( is ) - this.getAECurrentPower( is ) );
if( amount < requiredExt )
{
return 0;
}
return amount - requiredExt;
}
else
{
final double powerRemainder = this.injectAEPower( is, inputUnit.convertTo( PowerUnits.AE, amount ) );
return PowerUnits.AE.convertTo( inputUnit, powerRemainder );
}
}
@Override
public double injectAEPower( final ItemStack is, final double amt )
{