Did what I could with mj6

This commit is contained in:
AlgorithmX2 2014-05-09 21:08:56 -05:00
parent 2f071e7341
commit 3491fe4e33
14 changed files with 213 additions and 37 deletions

View file

@ -476,12 +476,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,10 @@
package appeng.integration.abstraction;
import appeng.tile.powersink.MinecraftJoules5;
public interface IMJ5
{
Object createPerdition(MinecraftJoules5 buildCraft);
}

View file

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

View file

@ -12,7 +12,7 @@ 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);

View file

@ -109,7 +109,8 @@ public class BC extends BaseModule implements IBC
{
if ( is == null )
return false;
return is.getItem() instanceof ItemFacade;
return is.getItem() instanceof ItemFacade && ItemFacade.getType( is ) == ItemFacade.TYPE_BASIC;
}
@Override
@ -189,7 +190,7 @@ public class BC extends BaseModule implements IBC
addFacade( b.blockQuartz.stack( 1 ) );
addFacade( b.blockQuartzChiseled.stack( 1 ) );
addFacade( b.blockQuartzPiller.stack( 1 ) );
Block skyStone = b.blockSkyStone.block();
if ( skyStone != null )
{
@ -211,8 +212,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
@ -224,8 +244,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,22 +1,22 @@
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 appeng.tile.powersink.MinecraftJoules5;
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(MinecraftJoules5 buildCraft)
{
if ( buildCraft instanceof IPowerReceptor )
return new MJPerdition( buildCraft );

View file

@ -0,0 +1,26 @@
package appeng.integration.modules;
import appeng.integration.BaseModule;
import appeng.integration.abstraction.IMJ6;
import buildcraft.api.mj.IBatteryObject;
public class MJ6 extends BaseModule implements IMJ6
{
public static MJ6 instance;
public MJ6() {
TestClass( IBatteryObject.class );
}
@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

@ -25,7 +25,7 @@ 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")
@Interface(iface = "buildcraft.api.power.IPowerReceptor", iname = "MJ5")
public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPowerReceptor, IGridTickable
{
@ -39,7 +39,7 @@ 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 );

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 MinecraftJoules5 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,87 @@
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 AERootPoweredTile implements IBatteryProvider, IBatteryObject
{
@Override
@Method(iname = "MJ6")
public double getEnergyRequested()
{
return getExternalPowerDemand( PowerUnits.MJ );
}
@Override
@Method(iname = "MJ6")
public double addEnergy(double amount)
{
double overflow = PowerUnits.MJ.convertTo( PowerUnits.AE, injectExternalPower( PowerUnits.MJ, amount ) );
return amount - overflow;
}
@Override
@Method(iname = "MJ6")
public double addEnergy(double amount, boolean ignoreCycleLimit)
{
double overflow = PowerUnits.MJ.convertTo( PowerUnits.AE, 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()
{
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" );