Merge branch 'mj6' of https://bitbucket.org/AlgorithmX2/appliedenergistics2
This commit is contained in:
@@ -475,12 +475,17 @@ public class Registration
|
|||||||
ph.registerNewLayer( "appeng.api.parts.layers.LayerIEnergySource", "ic2.api.energy.tile.IEnergySource" );
|
ph.registerNewLayer( "appeng.api.parts.layers.LayerIEnergySource", "ic2.api.energy.tile.IEnergySource" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( AppEng.instance.isIntegrationEnabled( "MJ" ) )
|
if ( AppEng.instance.isIntegrationEnabled( "MJ5" ) )
|
||||||
{
|
{
|
||||||
ph.registerNewLayer( "appeng.api.parts.layers.LayerIPowerEmitter", "buildcraft.api.power.IPowerEmitter" );
|
ph.registerNewLayer( "appeng.api.parts.layers.LayerIPowerEmitter", "buildcraft.api.power.IPowerEmitter" );
|
||||||
ph.registerNewLayer( "appeng.api.parts.layers.LayerIPowerReceptor", "buildcraft.api.power.IPowerReceptor" );
|
ph.registerNewLayer( "appeng.api.parts.layers.LayerIPowerReceptor", "buildcraft.api.power.IPowerReceptor" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( AppEng.instance.isIntegrationEnabled( "MJ6" ) )
|
||||||
|
{
|
||||||
|
ph.registerNewLayer( "appeng.api.parts.layers.LayerIBatteryProvider", "buildcraft.api.mj.IBatteryProvider" );
|
||||||
|
}
|
||||||
|
|
||||||
if ( AppEng.instance.isIntegrationEnabled( "RF" ) )
|
if ( AppEng.instance.isIntegrationEnabled( "RF" ) )
|
||||||
ph.registerNewLayer( "appeng.api.parts.layers.LayerIEnergyHandler", "cofh.api.energy.IEnergyHandler" );
|
ph.registerNewLayer( "appeng.api.parts.layers.LayerIEnergyHandler", "cofh.api.energy.IEnergyHandler" );
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
package appeng.integration.abstraction;
|
|
||||||
|
|
||||||
import appeng.tile.powersink.MinecraftJoules;
|
|
||||||
|
|
||||||
public interface IMJ
|
|
||||||
{
|
|
||||||
|
|
||||||
Object createPerdition(MinecraftJoules buildCraft);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package appeng.integration.abstraction;
|
||||||
|
|
||||||
|
|
||||||
|
public interface IMJ5
|
||||||
|
{
|
||||||
|
|
||||||
|
Object createPerdition(Object buildCraft);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package appeng.integration.abstraction;
|
||||||
|
|
||||||
|
|
||||||
|
public interface IMJ6
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,10 +12,10 @@ public abstract class BaseMJperdition extends AETileEventHandler
|
|||||||
super( TileEventType.TICK, TileEventType.WORLD_NBT );
|
super( TileEventType.TICK, TileEventType.WORLD_NBT );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Method(iname = "MJ")
|
@Method(iname = "MJ5")
|
||||||
public abstract PowerReceiver getPowerReceiver();
|
public abstract PowerReceiver getPowerReceiver();
|
||||||
|
|
||||||
public abstract double useEnergy(float f, float requred, boolean b);
|
public abstract double useEnergy(double f, double requred, boolean b);
|
||||||
|
|
||||||
public abstract void addEnergy(float failed);
|
public abstract void addEnergy(float failed);
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,15 @@ public class BC extends BaseModule implements IBC
|
|||||||
{
|
{
|
||||||
if ( is == null )
|
if ( is == null )
|
||||||
return false;
|
return false;
|
||||||
return is.getItem() instanceof ItemFacade;
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return is.getItem() instanceof ItemFacade && ItemFacade.getType( is ) == ItemFacade.TYPE_BASIC;
|
||||||
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
|
return is.getItem() instanceof ItemFacade;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -265,8 +273,27 @@ public class BC extends BaseModule implements IBC
|
|||||||
@Override
|
@Override
|
||||||
public IFacadePart createFacadePart(Block blk, int meta, ForgeDirection side)
|
public IFacadePart createFacadePart(Block blk, int meta, ForgeDirection side)
|
||||||
{
|
{
|
||||||
ItemStack fs = ItemFacade.getStack( blk, meta );
|
try
|
||||||
return new FacadePart( fs, side );
|
{
|
||||||
|
ItemStack fs = ItemFacade.getFacade( blk, meta );
|
||||||
|
return new FacadePart( fs, side );
|
||||||
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ItemStack fs = ItemFacade.getStack( blk, meta );
|
||||||
|
return new FacadePart( fs, side );
|
||||||
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -278,8 +305,31 @@ public class BC extends BaseModule implements IBC
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getTextureForFacade(ItemStack facade)
|
public ItemStack getTextureForFacade(ItemStack facade)
|
||||||
{
|
{
|
||||||
Block blk = ItemFacade.getBlock( facade );
|
try
|
||||||
return new ItemStack( blk, 1, ItemFacade.getMetaData( facade ) );
|
{
|
||||||
|
Block blk[] = ItemFacade.getBlocks( facade );
|
||||||
|
int meta[] = ItemFacade.getMetaValues( facade );
|
||||||
|
if ( blk == null || blk.length < 1 )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new ItemStack( blk[0], 1, meta[0] );
|
||||||
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Block blk = ItemFacade.getBlock( facade );
|
||||||
|
return new ItemStack( blk, 1, ItemFacade.getMetaData( facade ) );
|
||||||
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,36 +1,37 @@
|
|||||||
package appeng.integration.modules;
|
package appeng.integration.modules;
|
||||||
|
|
||||||
import appeng.integration.BaseModule;
|
import appeng.integration.BaseModule;
|
||||||
import appeng.integration.abstraction.IMJ;
|
import appeng.integration.abstraction.IMJ5;
|
||||||
import appeng.integration.modules.helpers.MJPerdition;
|
import appeng.integration.modules.helpers.MJPerdition;
|
||||||
import appeng.tile.powersink.MinecraftJoules;
|
|
||||||
import buildcraft.api.power.IPowerReceptor;
|
import buildcraft.api.power.IPowerReceptor;
|
||||||
|
|
||||||
public class MJ extends BaseModule implements IMJ
|
public class MJ5 extends BaseModule implements IMJ5
|
||||||
{
|
{
|
||||||
|
|
||||||
public static MJ instance;
|
public static MJ5 instance;
|
||||||
|
|
||||||
public MJ() {
|
public MJ5() {
|
||||||
TestClass( IPowerReceptor.class );
|
TestClass( IPowerReceptor.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createPerdition(MinecraftJoules buildCraft)
|
public Object createPerdition(Object buildCraft)
|
||||||
{
|
{
|
||||||
if ( buildCraft instanceof IPowerReceptor )
|
if ( buildCraft instanceof IPowerReceptor )
|
||||||
return new MJPerdition( buildCraft );
|
return new MJPerdition( (IPowerReceptor) buildCraft );
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Init() throws Throwable
|
public void Init() throws Throwable
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void PostInit() throws Throwable
|
public void PostInit() throws Throwable
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package appeng.integration.modules;
|
||||||
|
|
||||||
|
import appeng.integration.BaseModule;
|
||||||
|
import appeng.integration.abstraction.IMJ6;
|
||||||
|
import buildcraft.api.mj.IBatteryObject;
|
||||||
|
import buildcraft.api.mj.IBatteryProvider;
|
||||||
|
import buildcraft.api.mj.ISidedBatteryProvider;
|
||||||
|
|
||||||
|
public class MJ6 extends BaseModule implements IMJ6
|
||||||
|
{
|
||||||
|
|
||||||
|
public static MJ6 instance;
|
||||||
|
|
||||||
|
public MJ6() {
|
||||||
|
TestClass( IBatteryObject.class );
|
||||||
|
TestClass( IBatteryProvider.class );
|
||||||
|
TestClass( ISidedBatteryProvider.class );
|
||||||
|
throw new RuntimeException( "Disabled For Now!" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Init() throws Throwable
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void PostInit() throws Throwable
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package appeng.integration.modules.helpers;
|
||||||
|
|
||||||
|
|
||||||
|
public class MJBattery
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -41,7 +41,7 @@ public class MJPerdition extends BaseMJperdition
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double useEnergy(float min, float max, boolean doUse)
|
public double useEnergy(double min, double max, boolean doUse)
|
||||||
{
|
{
|
||||||
return bcPowerHandler.useEnergy( min, max, doUse );
|
return bcPowerHandler.useEnergy( min, max, doUse );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,9 +225,14 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
|
|||||||
public boolean useAlphaPass(ItemStack is)
|
public boolean useAlphaPass(ItemStack is)
|
||||||
{
|
{
|
||||||
ItemStack out = getTextureItem( is );
|
ItemStack out = getTextureItem( is );
|
||||||
|
|
||||||
|
if ( out == null || out.getItem() == null )
|
||||||
|
return false;
|
||||||
|
|
||||||
Block blk = Block.getBlockFromItem( out.getItem() );
|
Block blk = Block.getBlockFromItem( out.getItem() );
|
||||||
if ( blk != null && blk.canRenderInPass( 1 ) )
|
if ( blk != null && blk.canRenderInPass( 1 ) )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+270
-11
@@ -13,11 +13,19 @@ import appeng.api.networking.IGridNode;
|
|||||||
import appeng.api.networking.ticking.IGridTickable;
|
import appeng.api.networking.ticking.IGridTickable;
|
||||||
import appeng.api.networking.ticking.TickRateModulation;
|
import appeng.api.networking.ticking.TickRateModulation;
|
||||||
import appeng.api.networking.ticking.TickingRequest;
|
import appeng.api.networking.ticking.TickingRequest;
|
||||||
|
import appeng.core.AELog;
|
||||||
import appeng.core.AppEng;
|
import appeng.core.AppEng;
|
||||||
import appeng.core.settings.TickRates;
|
import appeng.core.settings.TickRates;
|
||||||
|
import appeng.integration.abstraction.IMJ5;
|
||||||
|
import appeng.integration.abstraction.helpers.BaseMJperdition;
|
||||||
import appeng.me.GridAccessException;
|
import appeng.me.GridAccessException;
|
||||||
import appeng.me.cache.helpers.TunnelCollection;
|
import appeng.me.cache.helpers.TunnelCollection;
|
||||||
import appeng.transformer.annotations.integration.Interface;
|
import appeng.transformer.annotations.integration.Interface;
|
||||||
|
import appeng.transformer.annotations.integration.InterfaceList;
|
||||||
|
import appeng.transformer.annotations.integration.Method;
|
||||||
|
import buildcraft.api.mj.IBatteryObject;
|
||||||
|
import buildcraft.api.mj.ISidedBatteryProvider;
|
||||||
|
import buildcraft.api.mj.MjAPI;
|
||||||
import buildcraft.api.power.IPowerReceptor;
|
import buildcraft.api.power.IPowerReceptor;
|
||||||
import buildcraft.api.power.PowerHandler;
|
import buildcraft.api.power.PowerHandler;
|
||||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||||
@@ -25,11 +33,13 @@ import buildcraft.api.power.PowerHandler.Type;
|
|||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
@Interface(iface = "buildcraft.api.power.IPowerReceptor", iname = "BC")
|
@InterfaceList(value = { @Interface(iface = "buildcraft.api.mj.ISidedBatteryProvider", iname = "MJ6"),
|
||||||
public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPowerReceptor, IGridTickable
|
@Interface(iface = "buildcraft.api.mj.IBatteryObject", iname = "MJ6"), @Interface(iface = "buildcraft.api.power.IPowerReceptor", iname = "MJ5"),
|
||||||
|
@Interface(iface = "appeng.api.networking.ticking.IGridTickable", iname = "MJ5") })
|
||||||
|
public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPowerReceptor, ISidedBatteryProvider, IBatteryObject, IGridTickable
|
||||||
{
|
{
|
||||||
|
|
||||||
PowerHandler pp;
|
BaseMJperdition pp;
|
||||||
|
|
||||||
public TunnelType getTunnelType()
|
public TunnelType getTunnelType()
|
||||||
{
|
{
|
||||||
@@ -39,20 +49,26 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
|
|||||||
public PartP2PBCPower(ItemStack is) {
|
public PartP2PBCPower(ItemStack is) {
|
||||||
super( is );
|
super( is );
|
||||||
|
|
||||||
if ( !AppEng.instance.isIntegrationEnabled( "MJ" ) )
|
if ( !AppEng.instance.isIntegrationEnabled( "MJ5" ) && !AppEng.instance.isIntegrationEnabled( "MJ6" ) )
|
||||||
throw new RuntimeException( "MJ Not installed!" );
|
throw new RuntimeException( "MJ Not installed!" );
|
||||||
|
|
||||||
pp = new PowerHandler( this, Type.MACHINE );
|
if ( AppEng.instance.isIntegrationEnabled( "MJ5" ) )
|
||||||
pp.configure( 1f, 320f, 800f, 640f );
|
{
|
||||||
|
pp = (BaseMJperdition) ((IMJ5) AppEng.instance.getIntegration( "MJ5" )).createPerdition( this );
|
||||||
|
if ( pp != null )
|
||||||
|
pp.configure( 1, 380, 1.0f / 5.0f, 1000 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Method(iname = "MJ5")
|
||||||
public TickingRequest getTickingRequest(IGridNode node)
|
public TickingRequest getTickingRequest(IGridNode node)
|
||||||
{
|
{
|
||||||
return new TickingRequest( TickRates.MJTunnel.min, TickRates.MJTunnel.max, false, false );
|
return new TickingRequest( TickRates.MJTunnel.min, TickRates.MJTunnel.max, false, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Method(iname = "MJ5")
|
||||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
|
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
|
||||||
{
|
{
|
||||||
if ( !output && proxy.isActive() )
|
if ( !output && proxy.isActive() )
|
||||||
@@ -93,7 +109,8 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
|
|||||||
if ( totalRequiredPower < 0.1 )
|
if ( totalRequiredPower < 0.1 )
|
||||||
return TickRateModulation.SLOWER;
|
return TickRateModulation.SLOWER;
|
||||||
|
|
||||||
double currentTotal = pp.getEnergyStored();
|
double currentTotal = pp.getPowerReceiver().getEnergyStored();
|
||||||
|
AELog.info( "currentTotal: " + currentTotal );
|
||||||
if ( currentTotal < 0.01 )
|
if ( currentTotal < 0.01 )
|
||||||
return TickRateModulation.SLOWER;
|
return TickRateModulation.SLOWER;
|
||||||
|
|
||||||
@@ -106,16 +123,19 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
|
|||||||
if ( tp != null )
|
if ( tp != null )
|
||||||
{
|
{
|
||||||
double howmuch = tp.powerRequest(); // orientation.getOpposite()
|
double howmuch = tp.powerRequest(); // orientation.getOpposite()
|
||||||
// );
|
AELog.info( "pulled: " + howmuch );
|
||||||
|
// );
|
||||||
if ( howmuch > tp.getMaxEnergyReceived() )
|
if ( howmuch > tp.getMaxEnergyReceived() )
|
||||||
howmuch = tp.getMaxEnergyReceived();
|
howmuch = tp.getMaxEnergyReceived();
|
||||||
|
|
||||||
|
AELog.info( "howmuch: " + howmuch );
|
||||||
if ( howmuch > 0.01 && howmuch > tp.getMinEnergyReceived() )
|
if ( howmuch > 0.01 && howmuch > tp.getMinEnergyReceived() )
|
||||||
{
|
{
|
||||||
double toPull = currentTotal * (howmuch / totalRequiredPower);
|
double toPull = currentTotal * (howmuch / totalRequiredPower);
|
||||||
double pulled = pp.useEnergy( 0, toPull, true );
|
double pulled = pp.useEnergy( 0, toPull, true );
|
||||||
QueueTunnelDrain( PowerUnits.MJ, pulled );
|
QueueTunnelDrain( PowerUnits.MJ, pulled );
|
||||||
|
|
||||||
|
AELog.info( "pulled: " + pulled );
|
||||||
tp.receiveEnergy( Type.PIPE, pulled, o.side.getOpposite() );
|
tp.receiveEnergy( Type.PIPE, pulled, o.side.getOpposite() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,6 +153,16 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
|
|||||||
return 0.5f;
|
return 0.5f;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
private IBatteryObject getTargetBattery()
|
||||||
|
{
|
||||||
|
TileEntity te = getWorld().getTileEntity( tile.xCoord + side.offsetX, tile.yCoord + side.offsetY, tile.zCoord + side.offsetZ );
|
||||||
|
if ( te != null )
|
||||||
|
return MjAPI.getMjBattery( te );
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Method(iname = "MJ5")
|
||||||
private IPowerReceptor getPowerTarget()
|
private IPowerReceptor getPowerTarget()
|
||||||
{
|
{
|
||||||
TileEntity te = getWorld().getTileEntity( tile.xCoord + side.offsetX, tile.yCoord + side.offsetY, tile.zCoord + side.offsetZ );
|
TileEntity te = getWorld().getTileEntity( tile.xCoord + side.offsetX, tile.yCoord + side.offsetY, tile.zCoord + side.offsetZ );
|
||||||
@@ -148,14 +178,16 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
|
|||||||
public void writeToNBT(NBTTagCompound tag)
|
public void writeToNBT(NBTTagCompound tag)
|
||||||
{
|
{
|
||||||
super.writeToNBT( tag );
|
super.writeToNBT( tag );
|
||||||
pp.writeToNBT( tag );
|
if ( pp != null )
|
||||||
|
pp.writeToNBT( tag );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound tag)
|
public void readFromNBT(NBTTagCompound tag)
|
||||||
{
|
{
|
||||||
super.readFromNBT( tag );
|
super.readFromNBT( tag );
|
||||||
pp.readFromNBT( tag );
|
if ( pp != null )
|
||||||
|
pp.readFromNBT( tag );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@@ -165,14 +197,16 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Method(iname = "MJ5")
|
||||||
public PowerReceiver getPowerReceiver(ForgeDirection side)
|
public PowerReceiver getPowerReceiver(ForgeDirection side)
|
||||||
{
|
{
|
||||||
if ( side.equals( side ) )
|
if ( side.equals( side ) )
|
||||||
return pp.getPowerReceiver();
|
return ((BaseMJperdition) pp).getPowerReceiver();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Method(iname = "MJ5")
|
||||||
public void doWork(PowerHandler workProvider)
|
public void doWork(PowerHandler workProvider)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -184,4 +218,229 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
|
|||||||
return tile.getWorldObj();
|
return tile.getWorldObj();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public IBatteryObject getMjBattery(String kind)
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public IBatteryObject getMjBattery(String kind, ForgeDirection direction)
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public double getEnergyRequested()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
double totalRequiredPower = 0.0f;
|
||||||
|
|
||||||
|
for (PartP2PBCPower g : getOutputs())
|
||||||
|
{
|
||||||
|
IBatteryObject o = g.getTargetBattery();
|
||||||
|
if ( o != null )
|
||||||
|
totalRequiredPower += o.getEnergyRequested();
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalRequiredPower;
|
||||||
|
}
|
||||||
|
catch (GridAccessException e)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public double addEnergy(double mj)
|
||||||
|
{
|
||||||
|
return addEnergyInternal( mj, false, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public double addEnergy(double mj, boolean ignoreCycleLimit)
|
||||||
|
{
|
||||||
|
return addEnergyInternal( mj, true, ignoreCycleLimit );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
private double addEnergyInternal(double mj, boolean cycleLimitMode, boolean ignoreCycleLimit)
|
||||||
|
{
|
||||||
|
if ( !output && proxy.isActive() )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
double originaInput = mj;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
TunnelCollection<PartP2PBCPower> outs = getOutputs();
|
||||||
|
|
||||||
|
double outputs = 0;
|
||||||
|
for (PartP2PBCPower g : outs)
|
||||||
|
{
|
||||||
|
IBatteryObject o = g.getTargetBattery();
|
||||||
|
if ( o != null )
|
||||||
|
{
|
||||||
|
outputs = outputs + 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( outputs < 0.0000001 )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
for (PartP2PBCPower g : outs)
|
||||||
|
{
|
||||||
|
IBatteryObject o = g.getTargetBattery();
|
||||||
|
if ( o != null )
|
||||||
|
{
|
||||||
|
double fraction = originaInput / outputs;
|
||||||
|
if ( cycleLimitMode )
|
||||||
|
fraction = o.addEnergy( fraction );
|
||||||
|
else
|
||||||
|
fraction = o.addEnergy( fraction, ignoreCycleLimit );
|
||||||
|
mj -= fraction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( mj > 0 )
|
||||||
|
{
|
||||||
|
for (PartP2PBCPower g : outs)
|
||||||
|
{
|
||||||
|
IBatteryObject o = g.getTargetBattery();
|
||||||
|
if ( o != null )
|
||||||
|
{
|
||||||
|
if ( cycleLimitMode )
|
||||||
|
mj = mj - o.addEnergy( mj );
|
||||||
|
else
|
||||||
|
mj = mj - o.addEnergy( mj, ignoreCycleLimit );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return originaInput - mj;
|
||||||
|
}
|
||||||
|
catch (GridAccessException e)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public double getEnergyStored()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
double totalRequiredPower = 0.0f;
|
||||||
|
|
||||||
|
for (PartP2PBCPower g : getOutputs())
|
||||||
|
{
|
||||||
|
IBatteryObject o = g.getTargetBattery();
|
||||||
|
if ( o != null )
|
||||||
|
totalRequiredPower += o.getEnergyStored();
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalRequiredPower;
|
||||||
|
}
|
||||||
|
catch (GridAccessException e)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public void setEnergyStored(double mj)
|
||||||
|
{
|
||||||
|
// EHh?!
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double maxCapacity()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
double totalRequiredPower = 0.0f;
|
||||||
|
|
||||||
|
for (PartP2PBCPower g : getOutputs())
|
||||||
|
{
|
||||||
|
IBatteryObject o = g.getTargetBattery();
|
||||||
|
if ( o != null )
|
||||||
|
totalRequiredPower += o.maxCapacity();
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalRequiredPower;
|
||||||
|
}
|
||||||
|
catch (GridAccessException e)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public double minimumConsumption()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
double totalRequiredPower = 1000000000000.0;
|
||||||
|
|
||||||
|
for (PartP2PBCPower g : getOutputs())
|
||||||
|
{
|
||||||
|
IBatteryObject o = g.getTargetBattery();
|
||||||
|
if ( o != null )
|
||||||
|
totalRequiredPower = Math.min( totalRequiredPower, o.minimumConsumption() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalRequiredPower;
|
||||||
|
}
|
||||||
|
catch (GridAccessException e)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public double maxReceivedPerCycle()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
double totalRequiredPower = 1000000.0;
|
||||||
|
|
||||||
|
for (PartP2PBCPower g : getOutputs())
|
||||||
|
{
|
||||||
|
IBatteryObject o = g.getTargetBattery();
|
||||||
|
if ( o != null )
|
||||||
|
totalRequiredPower = Math.min( totalRequiredPower, o.maxReceivedPerCycle() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalRequiredPower;
|
||||||
|
}
|
||||||
|
catch (GridAccessException e)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public IBatteryObject reconfigure(double maxCapacity, double maxReceivedPerCycle, double minimumConsumption)
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public String kind()
|
||||||
|
{
|
||||||
|
return "tunnel";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import appeng.transformer.annotations.integration.Interface;
|
|||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
|
||||||
@Interface(iname = "IC2", iface = "ic2.api.energy.tile.IEnergySink")
|
@Interface(iname = "IC2", iface = "ic2.api.energy.tile.IEnergySink")
|
||||||
public abstract class IC2 extends MinecraftJoules implements IEnergySink
|
public abstract class IC2 extends MinecraftJoules6 implements IEnergySink
|
||||||
{
|
{
|
||||||
|
|
||||||
boolean isInIC2 = false;
|
boolean isInIC2 = false;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import net.minecraft.world.World;
|
|||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import appeng.api.config.PowerUnits;
|
import appeng.api.config.PowerUnits;
|
||||||
import appeng.core.AppEng;
|
import appeng.core.AppEng;
|
||||||
import appeng.integration.abstraction.IMJ;
|
import appeng.integration.abstraction.IMJ5;
|
||||||
import appeng.integration.abstraction.helpers.BaseMJperdition;
|
import appeng.integration.abstraction.helpers.BaseMJperdition;
|
||||||
import appeng.transformer.annotations.integration.Interface;
|
import appeng.transformer.annotations.integration.Interface;
|
||||||
import appeng.transformer.annotations.integration.Method;
|
import appeng.transformer.annotations.integration.Method;
|
||||||
@@ -13,20 +13,20 @@ import buildcraft.api.power.IPowerReceptor;
|
|||||||
import buildcraft.api.power.PowerHandler;
|
import buildcraft.api.power.PowerHandler;
|
||||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||||
|
|
||||||
@Interface(iname = "BC", iface = "buildcraft.api.power.IPowerReceptor")
|
@Interface(iname = "MJ5", iface = "buildcraft.api.power.IPowerReceptor")
|
||||||
public abstract class MinecraftJoules extends AERootPoweredTile implements IPowerReceptor
|
public abstract class MinecraftJoules5 extends AERootPoweredTile implements IPowerReceptor
|
||||||
{
|
{
|
||||||
|
|
||||||
BaseMJperdition bcPowerWrapper;
|
BaseMJperdition bcPowerWrapper;
|
||||||
|
|
||||||
public MinecraftJoules() {
|
public MinecraftJoules5() {
|
||||||
if ( Platform.isServer() )
|
if ( Platform.isServer() )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ( AppEng.instance.isIntegrationEnabled( "MJ" ) )
|
if ( AppEng.instance.isIntegrationEnabled( "MJ5" ) )
|
||||||
{
|
{
|
||||||
IMJ mjIntegration = (IMJ) AppEng.instance.getIntegration( "MJ" );
|
IMJ5 mjIntegration = (IMJ5) AppEng.instance.getIntegration( "MJ5" );
|
||||||
if ( mjIntegration != null )
|
if ( mjIntegration != null )
|
||||||
{
|
{
|
||||||
addNewHandler( bcPowerWrapper = (BaseMJperdition) mjIntegration.createPerdition( this ) );
|
addNewHandler( bcPowerWrapper = (BaseMJperdition) mjIntegration.createPerdition( this ) );
|
||||||
@@ -43,7 +43,7 @@ public abstract class MinecraftJoules extends AERootPoweredTile implements IPowe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(iname = "BC")
|
@Method(iname = "MJ5")
|
||||||
final public PowerReceiver getPowerReceiver(ForgeDirection side)
|
final public PowerReceiver getPowerReceiver(ForgeDirection side)
|
||||||
{
|
{
|
||||||
if ( internalCanAcceptPower && getPowerSides().contains( side ) && bcPowerWrapper != null )
|
if ( internalCanAcceptPower && getPowerSides().contains( side ) && bcPowerWrapper != null )
|
||||||
@@ -52,7 +52,7 @@ public abstract class MinecraftJoules extends AERootPoweredTile implements IPowe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(iname = "BC")
|
@Method(iname = "MJ5")
|
||||||
final public void doWork(PowerHandler workProvider)
|
final public void doWork(PowerHandler workProvider)
|
||||||
{
|
{
|
||||||
float requred = (float) getExternalPowerDemand( PowerUnits.MJ );
|
float requred = (float) getExternalPowerDemand( PowerUnits.MJ );
|
||||||
@@ -62,7 +62,7 @@ public abstract class MinecraftJoules extends AERootPoweredTile implements IPowe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Method(iname = "BC")
|
@Method(iname = "MJ5")
|
||||||
final public World getWorld()
|
final public World getWorld()
|
||||||
{
|
{
|
||||||
return worldObj;
|
return worldObj;
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
package appeng.tile.powersink;
|
||||||
|
|
||||||
|
import appeng.api.config.PowerUnits;
|
||||||
|
import appeng.transformer.annotations.integration.Interface;
|
||||||
|
import appeng.transformer.annotations.integration.InterfaceList;
|
||||||
|
import appeng.transformer.annotations.integration.Method;
|
||||||
|
import buildcraft.api.mj.IBatteryObject;
|
||||||
|
import buildcraft.api.mj.IBatteryProvider;
|
||||||
|
|
||||||
|
@InterfaceList(value = { @Interface(iname = "MJ6", iface = "buildcraft.api.mj.IBatteryProvider"),
|
||||||
|
@Interface(iname = "MJ6", iface = "buildcraft.api.mj.IBatteryObject") })
|
||||||
|
public abstract class MinecraftJoules6 extends MinecraftJoules5 implements IBatteryProvider, IBatteryObject
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public String kind()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public double getEnergyRequested()
|
||||||
|
{
|
||||||
|
return getExternalPowerDemand( PowerUnits.MJ );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public double addEnergy(double amount)
|
||||||
|
{
|
||||||
|
double overflow = injectExternalPower( PowerUnits.MJ, amount );
|
||||||
|
return amount - overflow;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public double addEnergy(double amount, boolean ignoreCycleLimit)
|
||||||
|
{
|
||||||
|
double overflow = injectExternalPower( PowerUnits.MJ, amount );
|
||||||
|
return amount - overflow;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public double getEnergyStored()
|
||||||
|
{
|
||||||
|
return PowerUnits.AE.convertTo( PowerUnits.MJ, internalCurrentPower );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public void setEnergyStored(double mj)
|
||||||
|
{
|
||||||
|
internalCurrentPower = PowerUnits.MJ.convertTo( PowerUnits.AE, mj );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public double maxCapacity()
|
||||||
|
{
|
||||||
|
return PowerUnits.AE.convertTo( PowerUnits.MJ, internalMaxPower );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public double minimumConsumption()
|
||||||
|
{
|
||||||
|
return 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public double maxReceivedPerCycle()
|
||||||
|
{
|
||||||
|
return 999999.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public IBatteryObject reconfigure(double maxCapacity, double maxReceivedPerCycle, double minimumConsumption)
|
||||||
|
{
|
||||||
|
return getMjBattery( "" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Method(iname = "MJ6")
|
||||||
|
public IBatteryObject getMjBattery(String kind)
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -35,7 +35,8 @@ public class ASMIntegration implements IClassTransformer
|
|||||||
// integrationModules.add( IntegrationSide.BOTH, "Thermal Expansion", "ThermalExpansion", "TE" );
|
// integrationModules.add( IntegrationSide.BOTH, "Thermal Expansion", "ThermalExpansion", "TE" );
|
||||||
// integrationModules.add( IntegrationSide.BOTH, "Mystcraft", "Mystcraft", "Mystcraft" );
|
// integrationModules.add( IntegrationSide.BOTH, "Mystcraft", "Mystcraft", "Mystcraft" );
|
||||||
integrationModules.add( IntegrationSide.BOTH, "BuildCraft", "BuildCraft|Silicon", "BC" );
|
integrationModules.add( IntegrationSide.BOTH, "BuildCraft", "BuildCraft|Silicon", "BC" );
|
||||||
integrationModules.add( IntegrationSide.BOTH, "BuildCraft Power", null, "MJ" );
|
integrationModules.add( IntegrationSide.BOTH, "BuildCraft5 Power", null, "MJ5" );
|
||||||
|
integrationModules.add( IntegrationSide.BOTH, "BuildCraft6 Power", null, "MJ6" );
|
||||||
integrationModules.add( IntegrationSide.BOTH, "RedstoneFlux Power", null, "RF" );
|
integrationModules.add( IntegrationSide.BOTH, "RedstoneFlux Power", null, "RF" );
|
||||||
// integrationModules.add( IntegrationSide.BOTH, "Greg Tech", "gregtech_addon", "GT" );
|
// integrationModules.add( IntegrationSide.BOTH, "Greg Tech", "gregtech_addon", "GT" );
|
||||||
// integrationModules.add( IntegrationSide.BOTH, "Universal Electricity", null, "UE" );
|
// integrationModules.add( IntegrationSide.BOTH, "Universal Electricity", null, "UE" );
|
||||||
|
|||||||
Reference in New Issue
Block a user