Switched from FML Optional to AE Optional, lets me specify more interesting requirements for integration, and lets the config alter the resulting integration setup.

This commit is contained in:
AlgorithmX2
2014-04-06 01:55:24 -05:00
parent 97c06db6ef
commit 5248eeeace
32 changed files with 526 additions and 271 deletions
+55
View File
@@ -0,0 +1,55 @@
package appeng.tile.powersink;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.PowerUnits;
import appeng.transformer.annotations.integration.Interface;
import cofh.api.energy.IEnergyHandler;
@Interface(iname = "RF", iface = "cofh.api.energy.IEnergyHandler")
public abstract class RedstoneFlux extends RotaryCraft implements IEnergyHandler
{
@Override
final public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
{
if ( simulate )
{
double demand = getExternalPowerDemand( PowerUnits.RF );
if ( demand > maxReceive )
return maxReceive;
return (int) Math.floor( maxReceive - demand );
}
else
{
double overFlow = injectExternalPower( PowerUnits.RF, maxReceive );
double ox = Math.floor( overFlow );
internalCurrentPower += PowerUnits.RF.convertTo( PowerUnits.AE, overFlow - ox );
return maxReceive - (int) ox;
}
}
@Override
final public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate)
{
return 0;
}
@Override
final public boolean canInterface(ForgeDirection from)
{
return internalCanAcceptPower && getPowerSides().contains( from );
}
@Override
final public int getEnergyStored(ForgeDirection from)
{
return (int) Math.floor( PowerUnits.AE.convertTo( PowerUnits.RF, getAECurrentPower() ) );
}
@Override
final public int getMaxEnergyStored(ForgeDirection from)
{
return (int) Math.floor( PowerUnits.AE.convertTo( PowerUnits.RF, getAEMaxPower() ) );
}
}