2013-12-27 23:59:59 +01:00
|
|
|
package appeng.tile.powersink;
|
|
|
|
|
|
|
|
import net.minecraft.world.World;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.config.PowerUnits;
|
|
|
|
import appeng.core.AppEng;
|
2014-01-30 02:21:01 +01:00
|
|
|
import appeng.integration.abstraction.IMJ;
|
2014-02-16 19:41:45 +01:00
|
|
|
import appeng.integration.abstraction.helpers.BaseMJperdition;
|
2014-01-01 10:03:31 +01:00
|
|
|
import appeng.util.Platform;
|
2013-12-27 23:59:59 +01:00
|
|
|
import buildcraft.api.power.IPowerReceptor;
|
|
|
|
import buildcraft.api.power.PowerHandler;
|
|
|
|
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
|
|
|
import cpw.mods.fml.common.Optional.Interface;
|
|
|
|
import cpw.mods.fml.common.Optional.Method;
|
|
|
|
|
|
|
|
@Interface(modid = "BuildCraftAPI|power", iface = "buildcraft.api.power.IPowerReceptor")
|
|
|
|
public abstract class BuildCraft extends AERootPoweredTile implements IPowerReceptor
|
|
|
|
{
|
|
|
|
|
2014-02-16 19:41:45 +01:00
|
|
|
BaseMJperdition bcPowerWrapper;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
public BuildCraft() {
|
2014-01-01 10:03:31 +01:00
|
|
|
if ( Platform.isServer() )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-01-01 10:03:31 +01:00
|
|
|
try
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-01-30 02:21:01 +01:00
|
|
|
if ( AppEng.instance.isIntegrationEnabled( "MJ" ) )
|
2014-01-01 10:03:31 +01:00
|
|
|
{
|
2014-01-30 02:21:01 +01:00
|
|
|
IMJ mjIntegration = (IMJ) AppEng.instance.getIntegration( "MJ" );
|
|
|
|
if ( mjIntegration != null )
|
2014-01-28 21:38:06 +01:00
|
|
|
{
|
2014-01-30 02:21:01 +01:00
|
|
|
addNewHandler( bcPowerWrapper = mjIntegration.createPerdition( this ) );
|
|
|
|
if ( bcPowerWrapper != null )
|
2014-01-28 21:51:44 +01:00
|
|
|
bcPowerWrapper.configure( 1, 380, 1.0f / 5.0f, 1000 );
|
2014-01-28 21:38:06 +01:00
|
|
|
}
|
2014-01-01 10:03:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Throwable t)
|
|
|
|
{
|
|
|
|
// ignore.. no bc?
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Method(modid = "BuildCraftAPI|power")
|
|
|
|
final public PowerReceiver getPowerReceiver(ForgeDirection side)
|
|
|
|
{
|
2014-01-28 21:38:06 +01:00
|
|
|
if ( internalCanAcceptPower && getPowerSides().contains( side ) && bcPowerWrapper != null )
|
|
|
|
return bcPowerWrapper.getPowerReceiver();
|
2013-12-27 23:59:59 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Method(modid = "BuildCraftAPI|power")
|
|
|
|
final public void doWork(PowerHandler workProvider)
|
|
|
|
{
|
|
|
|
float requred = (float) getExternalPowerDemand( PowerUnits.MJ );
|
2014-01-28 21:38:06 +01:00
|
|
|
double failed = injectExternalPower( PowerUnits.MJ, bcPowerWrapper.useEnergy( 0.0f, requred, true ) );
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( failed > 0.01 )
|
2014-01-28 21:38:06 +01:00
|
|
|
bcPowerWrapper.addEnergy( (float) failed );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Method(modid = "BuildCraftAPI|power")
|
|
|
|
final public World getWorld()
|
|
|
|
{
|
|
|
|
return worldObj;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|