This commit is contained in:
AlgorithmX2 2014-05-11 17:06:33 -05:00
commit c72b272da9
16 changed files with 507 additions and 48 deletions

View file

@ -475,12 +475,17 @@ public class Registration
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.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" ) )
ph.registerNewLayer( "appeng.api.parts.layers.LayerIEnergyHandler", "cofh.api.energy.IEnergyHandler" );

View file

@ -1,10 +0,0 @@
package appeng.integration.abstraction;
import appeng.tile.powersink.MinecraftJoules;
public interface IMJ
{
Object createPerdition(MinecraftJoules buildCraft);
}

View file

@ -0,0 +1,9 @@
package appeng.integration.abstraction;
public interface IMJ5
{
Object createPerdition(Object buildCraft);
}

View file

@ -0,0 +1,7 @@
package appeng.integration.abstraction;
public interface IMJ6
{
}

View file

@ -12,10 +12,10 @@ public abstract class BaseMJperdition extends AETileEventHandler
super( TileEventType.TICK, TileEventType.WORLD_NBT );
}
@Method(iname = "MJ")
@Method(iname = "MJ5")
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);

View file

@ -118,7 +118,15 @@ public class BC extends BaseModule implements IBC
{
if ( is == null )
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
@ -265,8 +273,27 @@ public class BC extends BaseModule implements IBC
@Override
public IFacadePart createFacadePart(Block blk, int meta, ForgeDirection side)
{
ItemStack fs = ItemFacade.getStack( blk, meta );
return new FacadePart( fs, side );
try
{
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
@ -278,8 +305,31 @@ public class BC extends BaseModule implements IBC
@Override
public ItemStack getTextureForFacade(ItemStack facade)
{
Block blk = ItemFacade.getBlock( facade );
return new ItemStack( blk, 1, ItemFacade.getMetaData( facade ) );
try
{
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

View file

@ -1,36 +1,37 @@
package appeng.integration.modules;
import appeng.integration.BaseModule;
import appeng.integration.abstraction.IMJ;
import appeng.integration.abstraction.IMJ5;
import appeng.integration.modules.helpers.MJPerdition;
import appeng.tile.powersink.MinecraftJoules;
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 );
}
@Override
public Object createPerdition(MinecraftJoules buildCraft)
public Object createPerdition(Object buildCraft)
{
if ( buildCraft instanceof IPowerReceptor )
return new MJPerdition( buildCraft );
return new MJPerdition( (IPowerReceptor) buildCraft );
return null;
}
@Override
public void Init() throws Throwable
{
}
@Override
public void PostInit() throws Throwable
{
}
}

View file

@ -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
{
}
}

View file

@ -0,0 +1,7 @@
package appeng.integration.modules.helpers;
public class MJBattery
{
}

View file

@ -41,7 +41,7 @@ public class MJPerdition extends BaseMJperdition
}
@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 );
}

View file

@ -225,9 +225,14 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
public boolean useAlphaPass(ItemStack is)
{
ItemStack out = getTextureItem( is );
if ( out == null || out.getItem() == null )
return false;
Block blk = Block.getBlockFromItem( out.getItem() );
if ( blk != null && blk.canRenderInPass( 1 ) )
return true;
return false;
}

View file

@ -13,11 +13,19 @@ import appeng.api.networking.IGridNode;
import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.core.AELog;
import appeng.core.AppEng;
import appeng.core.settings.TickRates;
import appeng.integration.abstraction.IMJ5;
import appeng.integration.abstraction.helpers.BaseMJperdition;
import appeng.me.GridAccessException;
import appeng.me.cache.helpers.TunnelCollection;
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.PowerHandler;
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.SideOnly;
@Interface(iface = "buildcraft.api.power.IPowerReceptor", iname = "BC")
public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPowerReceptor, IGridTickable
@InterfaceList(value = { @Interface(iface = "buildcraft.api.mj.ISidedBatteryProvider", iname = "MJ6"),
@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()
{
@ -39,20 +49,26 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
public PartP2PBCPower(ItemStack is) {
super( is );
if ( !AppEng.instance.isIntegrationEnabled( "MJ" ) )
if ( !AppEng.instance.isIntegrationEnabled( "MJ5" ) && !AppEng.instance.isIntegrationEnabled( "MJ6" ) )
throw new RuntimeException( "MJ Not installed!" );
pp = new PowerHandler( this, Type.MACHINE );
pp.configure( 1f, 320f, 800f, 640f );
if ( AppEng.instance.isIntegrationEnabled( "MJ5" ) )
{
pp = (BaseMJperdition) ((IMJ5) AppEng.instance.getIntegration( "MJ5" )).createPerdition( this );
if ( pp != null )
pp.configure( 1, 380, 1.0f / 5.0f, 1000 );
}
}
@Override
@Method(iname = "MJ5")
public TickingRequest getTickingRequest(IGridNode node)
{
return new TickingRequest( TickRates.MJTunnel.min, TickRates.MJTunnel.max, false, false );
}
@Override
@Method(iname = "MJ5")
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
{
if ( !output && proxy.isActive() )
@ -93,7 +109,8 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
if ( totalRequiredPower < 0.1 )
return TickRateModulation.SLOWER;
double currentTotal = pp.getEnergyStored();
double currentTotal = pp.getPowerReceiver().getEnergyStored();
AELog.info( "currentTotal: " + currentTotal );
if ( currentTotal < 0.01 )
return TickRateModulation.SLOWER;
@ -106,16 +123,19 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
if ( tp != null )
{
double howmuch = tp.powerRequest(); // orientation.getOpposite()
// );
AELog.info( "pulled: " + howmuch );
// );
if ( howmuch > tp.getMaxEnergyReceived() )
howmuch = tp.getMaxEnergyReceived();
AELog.info( "howmuch: " + howmuch );
if ( howmuch > 0.01 && howmuch > tp.getMinEnergyReceived() )
{
double toPull = currentTotal * (howmuch / totalRequiredPower);
double pulled = pp.useEnergy( 0, toPull, true );
QueueTunnelDrain( PowerUnits.MJ, pulled );
AELog.info( "pulled: " + pulled );
tp.receiveEnergy( Type.PIPE, pulled, o.side.getOpposite() );
}
}
@ -133,6 +153,16 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
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()
{
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)
{
super.writeToNBT( tag );
pp.writeToNBT( tag );
if ( pp != null )
pp.writeToNBT( tag );
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
super.readFromNBT( tag );
pp.readFromNBT( tag );
if ( pp != null )
pp.readFromNBT( tag );
}
@SideOnly(Side.CLIENT)
@ -165,14 +197,16 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
}
@Override
@Method(iname = "MJ5")
public PowerReceiver getPowerReceiver(ForgeDirection side)
{
if ( side.equals( side ) )
return pp.getPowerReceiver();
return ((BaseMJperdition) pp).getPowerReceiver();
return null;
}
@Override
@Method(iname = "MJ5")
public void doWork(PowerHandler workProvider)
{
@ -184,4 +218,229 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
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";
}
}

View file

@ -13,7 +13,7 @@ import appeng.transformer.annotations.integration.Interface;
import appeng.util.Platform;
@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;

View file

@ -4,7 +4,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.PowerUnits;
import appeng.core.AppEng;
import appeng.integration.abstraction.IMJ;
import appeng.integration.abstraction.IMJ5;
import appeng.integration.abstraction.helpers.BaseMJperdition;
import appeng.transformer.annotations.integration.Interface;
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.PowerReceiver;
@Interface(iname = "BC", iface = "buildcraft.api.power.IPowerReceptor")
public abstract class MinecraftJoules extends AERootPoweredTile implements IPowerReceptor
@Interface(iname = "MJ5", iface = "buildcraft.api.power.IPowerReceptor")
public abstract class MinecraftJoules5 extends AERootPoweredTile implements IPowerReceptor
{
BaseMJperdition bcPowerWrapper;
public MinecraftJoules() {
public MinecraftJoules5() {
if ( Platform.isServer() )
{
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 )
{
addNewHandler( bcPowerWrapper = (BaseMJperdition) mjIntegration.createPerdition( this ) );
@ -43,7 +43,7 @@ public abstract class MinecraftJoules extends AERootPoweredTile implements IPowe
}
@Override
@Method(iname = "BC")
@Method(iname = "MJ5")
final public PowerReceiver getPowerReceiver(ForgeDirection side)
{
if ( internalCanAcceptPower && getPowerSides().contains( side ) && bcPowerWrapper != null )
@ -52,7 +52,7 @@ public abstract class MinecraftJoules extends AERootPoweredTile implements IPowe
}
@Override
@Method(iname = "BC")
@Method(iname = "MJ5")
final public void doWork(PowerHandler workProvider)
{
float requred = (float) getExternalPowerDemand( PowerUnits.MJ );
@ -62,7 +62,7 @@ public abstract class MinecraftJoules extends AERootPoweredTile implements IPowe
}
@Override
@Method(iname = "BC")
@Method(iname = "MJ5")
final public World getWorld()
{
return worldObj;

View file

@ -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;
}
}

View file

@ -35,7 +35,8 @@ public class ASMIntegration implements IClassTransformer
// integrationModules.add( IntegrationSide.BOTH, "Thermal Expansion", "ThermalExpansion", "TE" );
// integrationModules.add( IntegrationSide.BOTH, "Mystcraft", "Mystcraft", "Mystcraft" );
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, "Greg Tech", "gregtech_addon", "GT" );
// integrationModules.add( IntegrationSide.BOTH, "Universal Electricity", null, "UE" );