Applied-Energistics-2-tiler.../tile/powersink/MekJoules.java
AlgorithmX2 9223f724bf Added Feature: #0715 - Mekanism recipes
Added Feature: #0702 - Mekanism Power for Energy Acceptor
2014-07-24 22:20:52 -05:00

43 lines
1.2 KiB
Java

package appeng.tile.powersink;
import mekanism.api.energy.IStrictEnergyAcceptor;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.PowerUnits;
import appeng.transformer.annotations.integration.Interface;
@Interface(iname = "Mekanism", iface = "mekanism.api.energy.IStrictEnergyAcceptor")
public abstract class MekJoules extends RedstoneFlux implements IStrictEnergyAcceptor {
@Override
public double getEnergy() {
return 0;
}
@Override
public void setEnergy(double energy) {
double extra = injectExternalPower( PowerUnits.MK, energy );
internalCurrentPower += PowerUnits.MK.convertTo(PowerUnits.AE, extra );
}
@Override
public double getMaxEnergy() {
return this.getExternalPowerDemand( PowerUnits.MK, 100000 );
}
@Override
public double transferEnergyToAcceptor(ForgeDirection side, double amount)
{
double demand = getExternalPowerDemand( PowerUnits.MK, Double.MAX_VALUE );
if ( amount > demand )
amount = demand;
double overflow = injectExternalPower( PowerUnits.MK, amount );
return amount - overflow;
}
@Override
public boolean canReceiveEnergy(ForgeDirection side) {
return getPowerSides().contains(side);
}
}