Applied-Energistics-2-tiler.../integration/modules/MJ6.java

116 lines
2.4 KiB
Java
Raw Normal View History

2014-05-10 04:08:56 +02:00
package appeng.integration.modules;
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;
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;
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
{
}
@Override
@Method(iname = "MJ5")
public IBatteryObject provider(final TileEntity te, final ForgeDirection side)
{
if ( te instanceof IPowerReceptor )
{
final IPowerReceptor recp = (IPowerReceptor) te;
if ( recp == null )
return null;
final PowerReceiver ph = recp.getPowerReceiver( side );
if ( ph == null )
return null;
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
}