2014-05-10 04:08:56 +02:00
|
|
|
package appeng.integration.modules;
|
|
|
|
|
2014-05-21 05:06:37 +02:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2014-05-10 04:08:56 +02:00
|
|
|
import appeng.integration.BaseModule;
|
|
|
|
import appeng.integration.abstraction.IMJ6;
|
2014-05-21 05:06:37 +02:00
|
|
|
import appeng.transformer.annotations.integration.Method;
|
2014-05-10 04:08:56 +02:00
|
|
|
import buildcraft.api.mj.IBatteryObject;
|
2014-05-12 00:01:31 +02:00
|
|
|
import buildcraft.api.mj.IBatteryProvider;
|
|
|
|
import buildcraft.api.mj.ISidedBatteryProvider;
|
2014-05-21 05:06:37 +02:00
|
|
|
import buildcraft.api.mj.MjAPI;
|
|
|
|
import buildcraft.api.power.IPowerReceptor;
|
|
|
|
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
|
|
|
import buildcraft.api.power.PowerHandler.Type;
|
2014-05-10 04:08:56 +02:00
|
|
|
|
|
|
|
public class MJ6 extends BaseModule implements IMJ6
|
|
|
|
{
|
|
|
|
|
|
|
|
public static MJ6 instance;
|
|
|
|
|
|
|
|
public MJ6() {
|
|
|
|
TestClass( IBatteryObject.class );
|
2014-05-12 00:01:31 +02:00
|
|
|
TestClass( IBatteryProvider.class );
|
|
|
|
TestClass( ISidedBatteryProvider.class );
|
2014-05-10 04:08:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void Init() throws Throwable
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void PostInit() throws Throwable
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-05-21 05:06:37 +02:00
|
|
|
@Override
|
|
|
|
@Method(iname = "MJ5")
|
|
|
|
public IBatteryObject provider(final TileEntity te, final ForgeDirection side)
|
|
|
|
{
|
|
|
|
if ( te instanceof IPowerReceptor )
|
|
|
|
{
|
|
|
|
final IPowerReceptor recp = (IPowerReceptor) te;
|
2014-05-22 16:20:59 +02:00
|
|
|
if ( recp == null )
|
|
|
|
return null;
|
2014-05-21 05:06:37 +02:00
|
|
|
final PowerReceiver ph = recp.getPowerReceiver( side );
|
2014-05-22 16:20:59 +02:00
|
|
|
if ( ph == null )
|
|
|
|
return null;
|
2014-05-21 05:06:37 +02:00
|
|
|
|
|
|
|
return new IBatteryObject() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setEnergyStored(double mj)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IBatteryObject reconfigure(double maxCapacity, double maxReceivedPerCycle, double minimumConsumption)
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public double minimumConsumption()
|
|
|
|
{
|
|
|
|
return ph.getMinEnergyReceived();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public double maxReceivedPerCycle()
|
|
|
|
{
|
|
|
|
return ph.getMaxEnergyReceived();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public double maxCapacity()
|
|
|
|
{
|
|
|
|
return ph.getMaxEnergyStored();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String kind()
|
|
|
|
{
|
|
|
|
return MjAPI.DEFAULT_POWER_FRAMEWORK;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public double getEnergyStored()
|
|
|
|
{
|
|
|
|
return ph.getEnergyStored();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public double getEnergyRequested()
|
|
|
|
{
|
|
|
|
return ph.getMaxEnergyStored() - ph.getEnergyStored();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public double addEnergy(double mj, boolean ignoreCycleLimit)
|
|
|
|
{
|
|
|
|
return ph.receiveEnergy( Type.PIPE, mj, side );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public double addEnergy(double mj)
|
|
|
|
{
|
|
|
|
return ph.receiveEnergy( Type.PIPE, mj, side );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2014-05-10 04:08:56 +02:00
|
|
|
}
|