Switched from FML Optional to AE Optional, lets me specify more interesting requirements for integration, and lets the config alter the resulting integration setup.
This commit is contained in:
@@ -32,8 +32,11 @@ public class IntegrationNode
|
||||
|
||||
void Call(IntegrationStage stage)
|
||||
{
|
||||
if ( isActive() )
|
||||
if ( state != IntegrationStage.FAILED )
|
||||
{
|
||||
if ( state.ordinal() > stage.ordinal() )
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
switch (stage)
|
||||
@@ -100,6 +103,9 @@ public class IntegrationNode
|
||||
|
||||
public boolean isActive()
|
||||
{
|
||||
if ( state == IntegrationStage.PREINIT )
|
||||
Call( IntegrationStage.PREINIT );
|
||||
|
||||
return state != IntegrationStage.FAILED;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@ package appeng.integration;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class IntegrationRegistry
|
||||
{
|
||||
@@ -11,71 +12,19 @@ public class IntegrationRegistry
|
||||
|
||||
private LinkedList<IntegrationNode> modules = new LinkedList<IntegrationNode>();
|
||||
|
||||
public void loadIntegration(IntegrationSide side, String dspname, String modID, String name)
|
||||
public void add(IntegrationSide side, String dspname, String modID, String name)
|
||||
{
|
||||
if ( side == IntegrationSide.CLIENT && Platform.isServer() )
|
||||
if ( side == IntegrationSide.CLIENT && FMLLaunchHandler.side() == Side.SERVER )
|
||||
return;
|
||||
|
||||
if ( side == IntegrationSide.SERVER && Platform.isClient() )
|
||||
if ( side == IntegrationSide.SERVER && FMLLaunchHandler.side() == Side.CLIENT )
|
||||
return;
|
||||
|
||||
modules.add( new IntegrationNode( dspname, modID, name, "appeng.integration.modules." + name ) );
|
||||
}
|
||||
|
||||
private void die()
|
||||
{
|
||||
throw new RuntimeException( "Invalid Mod Integration Registry config, please check parameters." );
|
||||
}
|
||||
|
||||
public IntegrationRegistry(Object[] name) {
|
||||
public IntegrationRegistry() {
|
||||
instance = this;
|
||||
|
||||
int stage = 0;
|
||||
|
||||
IntegrationSide side = null;
|
||||
String dspName = null;
|
||||
String modID = null;
|
||||
for (Object n : name)
|
||||
{
|
||||
stage++;
|
||||
if ( stage == 1 )
|
||||
{
|
||||
if ( n instanceof IntegrationSide )
|
||||
side = (IntegrationSide) n;
|
||||
else
|
||||
die();
|
||||
}
|
||||
else if ( stage == 2 )
|
||||
{
|
||||
if ( n instanceof String )
|
||||
dspName = (String) n;
|
||||
else
|
||||
die();
|
||||
}
|
||||
else if ( stage == 3 )
|
||||
{
|
||||
if ( n instanceof String || n == null )
|
||||
modID = (String) n;
|
||||
else
|
||||
die();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( n instanceof String )
|
||||
{
|
||||
loadIntegration( side, dspName, modID, (String) n );
|
||||
side = null;
|
||||
dspName = null;
|
||||
modID = null;
|
||||
stage = 0;
|
||||
}
|
||||
else
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
if ( dspName != null || modID != null )
|
||||
die();
|
||||
}
|
||||
|
||||
public void init()
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import appeng.integration.abstraction.helpers.BaseMJperdition;
|
||||
import appeng.tile.powersink.BuildCraft;
|
||||
import appeng.tile.powersink.MinecraftJoules;
|
||||
|
||||
public interface IMJ
|
||||
{
|
||||
|
||||
BaseMJperdition createPerdition(BuildCraft buildCraft);
|
||||
Object createPerdition(MinecraftJoules buildCraft);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package appeng.integration.abstraction.helpers;
|
||||
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.transformer.annotations.integration.Method;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
|
||||
public abstract class BaseMJperdition extends AETileEventHandler
|
||||
{
|
||||
@@ -12,7 +12,7 @@ public abstract class BaseMJperdition extends AETileEventHandler
|
||||
super( TileEventType.TICK, TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Method(modid = "BuildCraftAPI|power")
|
||||
@Method(iname = "MJ")
|
||||
public abstract PowerReceiver getPowerReceiver();
|
||||
|
||||
public abstract double useEnergy(float f, float requred, boolean b);
|
||||
|
||||
@@ -32,6 +32,12 @@ public class BC extends BaseModule implements IBC
|
||||
|
||||
public static BC instance;
|
||||
|
||||
public BC() {
|
||||
TestClass( IPipeConnection.class );
|
||||
TestClass( ItemFacade.class );
|
||||
TestClass( IToolWrench.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFacade(ItemStack item)
|
||||
{
|
||||
@@ -174,10 +180,6 @@ public class BC extends BaseModule implements IBC
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
TestClass( IPipeConnection.class );
|
||||
TestClass( ItemFacade.class );
|
||||
TestClass( IToolWrench.class );
|
||||
|
||||
AEApi.instance().partHelper().registerNewLayer( "appeng.api.parts.layers.LayerIPipeConnection", "buildcraft.api.transport.IPipeConnection" );
|
||||
AEApi.instance().registries().externalStorage().addExternalStorageInterface( new BCPipeHandler() );
|
||||
|
||||
|
||||
@@ -8,18 +8,22 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.TunnelType;
|
||||
import appeng.api.features.IP2PTunnelRegistry;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.abstraction.IIC2;
|
||||
|
||||
public class IC2 implements IIntegrationModule, IIC2
|
||||
public class IC2 extends BaseModule implements IIntegrationModule, IIC2
|
||||
{
|
||||
|
||||
public static IC2 instance;
|
||||
|
||||
public IC2() {
|
||||
TestClass( IEnergyTile.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import powercrystals.minefactoryreloaded.api.rednet.RedNetConnectionType;
|
||||
import appeng.integration.BaseModule;
|
||||
|
||||
public class MFR extends BaseModule
|
||||
{
|
||||
|
||||
public static MFR instance;
|
||||
|
||||
public MFR() {
|
||||
TestClass( RedNetConnectionType.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,9 +2,8 @@ package appeng.integration.modules;
|
||||
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.abstraction.IMJ;
|
||||
import appeng.integration.abstraction.helpers.BaseMJperdition;
|
||||
import appeng.integration.modules.helpers.MJPerdition;
|
||||
import appeng.tile.powersink.BuildCraft;
|
||||
import appeng.tile.powersink.MinecraftJoules;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
|
||||
public class MJ extends BaseModule implements IMJ
|
||||
@@ -12,8 +11,12 @@ public class MJ extends BaseModule implements IMJ
|
||||
|
||||
public static MJ instance;
|
||||
|
||||
public MJ() {
|
||||
TestClass( IPowerReceptor.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseMJperdition createPerdition(BuildCraft buildCraft)
|
||||
public Object createPerdition(MinecraftJoules buildCraft)
|
||||
{
|
||||
if ( buildCraft instanceof IPowerReceptor )
|
||||
return new MJPerdition( buildCraft );
|
||||
@@ -23,13 +26,11 @@ public class MJ extends BaseModule implements IMJ
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
TestClass( MJPerdition.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
|
||||
public class RF extends BaseModule implements IIntegrationModule
|
||||
{
|
||||
|
||||
public static RF instance;
|
||||
|
||||
public RF() {
|
||||
TestClass( cofh.api.energy.IEnergyHandler.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import appeng.integration.BaseModule;
|
||||
|
||||
public class RotaryCraft extends BaseModule
|
||||
{
|
||||
|
||||
public static RotaryCraft instance;
|
||||
|
||||
public RotaryCraft() {
|
||||
TestClass( Reika.RotaryCraft.API.ShaftPowerReceiver.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package appeng.integration.modules.dead;
|
||||
package appeng.integration.modules;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -6,12 +6,12 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.abstraction.ITE;
|
||||
import cofh.api.transport.IItemConduit;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
|
||||
public class TE implements IIntegrationModule, ITE
|
||||
public class TE extends BaseModule implements IIntegrationModule, ITE
|
||||
{
|
||||
|
||||
public static TE instance;
|
||||
@@ -19,7 +19,6 @@ public class TE implements IIntegrationModule, ITE
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user