Merge branch 'master' of https://bitbucket.org/AlgorithmX2/appliedenergistics2 into rv1
This commit is contained in:
commit
ee42c53f89
37 changed files with 578 additions and 285 deletions
|
@ -236,20 +236,40 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo
|
|||
super.save();
|
||||
}
|
||||
|
||||
public int getFreeMaterial()
|
||||
public int getFreeIDSLot(int varID, String Category)
|
||||
{
|
||||
boolean alreadyUsed = false;
|
||||
int min = 0;
|
||||
for (Property p : getCategory( "materials" ).getValues().values())
|
||||
min = Math.max( min, p.getInt() + 1 );
|
||||
return min;
|
||||
|
||||
for (Property p : getCategory( Category ).getValues().values())
|
||||
{
|
||||
int thisInt = p.getInt();
|
||||
|
||||
if ( varID == thisInt )
|
||||
alreadyUsed = true;
|
||||
|
||||
min = Math.max( min, thisInt + 1 );
|
||||
}
|
||||
|
||||
if ( alreadyUsed )
|
||||
{
|
||||
if ( min < 1000 )
|
||||
min = 1000;
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
return varID;
|
||||
}
|
||||
|
||||
public int getFreePart()
|
||||
public int getFreeMaterial(int varID)
|
||||
{
|
||||
int min = 0;
|
||||
for (Property p : getCategory( "parts" ).getValues().values())
|
||||
min = Math.max( min, p.getInt() + 1 );
|
||||
return min;
|
||||
return getFreeIDSLot( varID, "materials" );
|
||||
}
|
||||
|
||||
public int getFreePart(int varID)
|
||||
{
|
||||
return getFreeIDSLot( varID, "parts" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,7 +10,6 @@ import appeng.core.sync.GuiBridge;
|
|||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationSide;
|
||||
import appeng.server.AECommand;
|
||||
import appeng.services.Profiler;
|
||||
import appeng.services.VersionChecker;
|
||||
|
@ -65,43 +64,14 @@ public class AppEng
|
|||
FMLCommonHandler.instance().registerCrashCallable( new CrashEnhancement( ci ) );
|
||||
}
|
||||
|
||||
private IntegrationRegistry integrationModules = new IntegrationRegistry( new Object[] {
|
||||
|
||||
/**
|
||||
* Side, Display Name, ModID ClassPostFix
|
||||
*/
|
||||
IntegrationSide.BOTH, "Industrial Craft 2", "IC2", "IC2", // IC2
|
||||
// IntegrationSide.BOTH, "Railcraft", "Railcraft", "RC", // RC
|
||||
// IntegrationSide.BOTH, "Thermal Expansion", "ThermalExpansion", "TE", // TE
|
||||
// IntegrationSide.BOTH, "Mystcraft", "Mystcraft", "Mystcraft", // MC
|
||||
IntegrationSide.BOTH, "BuildCraft", "BuildCraft|Silicon", "BC", // BC
|
||||
IntegrationSide.BOTH, "BuildCraft Power", null, "MJ", // BC
|
||||
// IntegrationSide.BOTH, "Greg Tech", "gregtech_addon", "GT", // GT
|
||||
// IntegrationSide.BOTH, "Universal Electricity", null, "UE", // UE
|
||||
// IntegrationSide.BOTH, "Logistics Pipes", "LogisticsPipes|Main", "LP", // LP
|
||||
// IntegrationSide.CLIENT, "Inventory Tweaks", "", "InvTweaks", // InvTweaks
|
||||
// IntegrationSide.BOTH, "Mine Factory Reloaded", "MineFactoryReloaded", "MFR", // MFR
|
||||
IntegrationSide.BOTH, "Deep Storage Unit", null, "DSU", // DSU
|
||||
// IntegrationSide.BOTH, "Better Storage", "betterstorage", "BS", // BS
|
||||
IntegrationSide.BOTH, "Factorization", "factorization", "FZ", // FZ
|
||||
// IntegrationSide.BOTH, "Forestry", "Forestry", "Forestry", // Forestry
|
||||
// IntegrationSide.BOTH, "Mekanism", "Mekanism", "Mekanism", // MeK
|
||||
IntegrationSide.CLIENT, "Waila", "Waila", "Waila", // Waila
|
||||
IntegrationSide.BOTH, "Rotatable Blocks", "RotatableBlocks", "RB", // RB
|
||||
IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks", "InvTweaks", // INV
|
||||
IntegrationSide.CLIENT, "Not Enough Items", "NotEnoughItems", "NEI", // NEI
|
||||
IntegrationSide.CLIENT, "Craft Guide", "craftguide", "CraftGuide", // CraftGuide
|
||||
IntegrationSide.BOTH, "Forge MultiPart", "McMultipart", "FMP" // FMP
|
||||
} );
|
||||
|
||||
public boolean isIntegrationEnabled(String Name)
|
||||
{
|
||||
return integrationModules.isEnabled( Name );
|
||||
return IntegrationRegistry.instance.isEnabled( Name );
|
||||
}
|
||||
|
||||
public Object getIntegration(String Name)
|
||||
{
|
||||
return integrationModules.getInstance( Name );
|
||||
return IntegrationRegistry.instance.getInstance( Name );
|
||||
}
|
||||
|
||||
private void startService(String serviceName, Thread thread)
|
||||
|
@ -154,7 +124,7 @@ public class AppEng
|
|||
AELog.info( "Init" );
|
||||
|
||||
Registration.instance.Init( event );
|
||||
integrationModules.init();
|
||||
IntegrationRegistry.instance.init();
|
||||
|
||||
AELog.info( "Init ( end " + star.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
|
||||
}
|
||||
|
@ -166,7 +136,7 @@ public class AppEng
|
|||
AELog.info( "PostInit" );
|
||||
|
||||
Registration.instance.PostInit( event );
|
||||
integrationModules.postinit();
|
||||
IntegrationRegistry.instance.postinit();
|
||||
|
||||
AEConfig.instance.save();
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@ package appeng.helpers;
|
|||
import powercrystals.minefactoryreloaded.api.rednet.IConnectableRedNet;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
|
||||
@Interface(iface = "powercrystals.minefactoryreloaded.api.rednet.IConnectableRedNet", modid = "MineFactoryReloaded")
|
||||
@Interface(iface = "powercrystals.minefactoryreloaded.api.rednet.IConnectableRedNet", iname = "MFR")
|
||||
public interface AEMultiTile extends IGridHost, IPartHost, IConnectableRedNet
|
||||
{
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
@ -175,10 +181,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
|
||||
|
|
27
integration/modules/MFR.java
Normal file
27
integration/modules/MFR.java
Normal file
|
@ -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
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,11 +11,15 @@ public class NEI implements IIntegrationModule
|
|||
|
||||
public static NEI instance;
|
||||
|
||||
Class API;
|
||||
|
||||
public NEI() throws ClassNotFoundException {
|
||||
API = Class.forName( "codechicken.nei.api.API" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
Class API = Class.forName( "codechicken.nei.api.API" );
|
||||
|
||||
Method registerRecipeHandler = API.getDeclaredMethod( "registerRecipeHandler", new Class[] { codechicken.nei.recipe.ICraftingHandler.class } );
|
||||
Method registerUsageHandler = API.getDeclaredMethod( "registerUsageHandler", new Class[] { codechicken.nei.recipe.IUsageHandler.class } );
|
||||
|
||||
|
|
27
integration/modules/RF.java
Normal file
27
integration/modules/RF.java
Normal file
|
@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
26
integration/modules/RotaryCraft.java
Normal file
26
integration/modules/RotaryCraft.java
Normal file
|
@ -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
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ public class ItemMaterial extends AEBaseItem implements IStorageComponent, IUpgr
|
|||
|
||||
if ( enabled )
|
||||
{
|
||||
int newMaterialNum = AEConfig.instance.get( "materials", name, AEConfig.instance.getFreeMaterial() ).getInt();
|
||||
int newMaterialNum = AEConfig.instance.get( "materials", name, AEConfig.instance.getFreeMaterial( mat.ordinal() ) ).getInt();
|
||||
mat.damageValue = newMaterialNum;
|
||||
ItemStackSrc output = new ItemStackSrc( this, newMaterialNum );
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ public class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
|
|||
|
||||
if ( enabled )
|
||||
{
|
||||
int newPartNum = AEConfig.instance.get( "parts", name, AEConfig.instance.getFreePart() ).getInt();
|
||||
int newPartNum = AEConfig.instance.get( "parts", name, AEConfig.instance.getFreePart( varID ) ).getInt();
|
||||
ItemStackSrc output = new ItemStackSrc( this, newPartNum );
|
||||
|
||||
PartTypeIst pti = new PartTypeIst();
|
||||
|
|
|
@ -23,11 +23,11 @@ import appeng.core.sync.network.NetworkHandler;
|
|||
import appeng.core.sync.packets.PacketClick;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.NetworkToolViewer;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
import appeng.util.Platform;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
|
||||
@Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraftAPI|core")
|
||||
@Interface(iface = "buildcraft.api.tools.IToolWrench", iname = "BC")
|
||||
public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench, IToolWrench
|
||||
{
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package appeng.items.tools.powered.powersink;
|
||||
|
||||
public class AEBasePoweredItem extends ThermalExpansion
|
||||
public class AEBasePoweredItem extends RedstoneFlux
|
||||
{
|
||||
|
||||
public AEBasePoweredItem(Class c, String subname) {
|
||||
|
|
|
@ -4,9 +4,9 @@ import ic2.api.item.IElectricItemManager;
|
|||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
|
||||
@Interface(iface = "ic2.api.item.IElectricItemManager", modid = "IC2")
|
||||
@Interface(iface = "ic2.api.item.IElectricItemManager", iname = "IC2")
|
||||
public class IC2 extends AERootPoweredItem implements IElectricItemManager
|
||||
{
|
||||
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
package appeng.items.tools.powered.powersink;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
|
||||
@Interface(iface = "cofh.api.energy.IEnergyContainerItem", modid = "ThermalExpansion")
|
||||
public class ThermalExpansion extends IC2 implements IEnergyContainerItem
|
||||
{
|
||||
|
||||
public ThermalExpansion(Class c, String subname) {
|
||||
super( c, subname );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ItemStack is, int maxReceive, boolean simulate)
|
||||
{
|
||||
return maxReceive - (int) injectExternalPower( PowerUnits.RF, is, maxReceive, simulate );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ItemStack is)
|
||||
{
|
||||
return (int) PowerUnits.AE.convertTo( PowerUnits.RF, getAECurrentPower( is ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ItemStack is)
|
||||
{
|
||||
return (int) PowerUnits.AE.convertTo( PowerUnits.RF, getAEMaxPower( is ) );
|
||||
}
|
||||
|
||||
}
|
||||
package appeng.items.tools.powered.powersink;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
|
||||
@Interface(iface = "cofh.api.energy.IEnergyContainerItem", iname = "RF")
|
||||
public class RedstoneFlux extends IC2 implements IEnergyContainerItem
|
||||
{
|
||||
|
||||
public RedstoneFlux(Class c, String subname) {
|
||||
super( c, subname );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ItemStack is, int maxReceive, boolean simulate)
|
||||
{
|
||||
return maxReceive - (int) injectExternalPower( PowerUnits.RF, is, maxReceive, simulate );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ItemStack is)
|
||||
{
|
||||
return (int) PowerUnits.AE.convertTo( PowerUnits.RF, getAECurrentPower( is ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ItemStack is)
|
||||
{
|
||||
return (int) PowerUnits.AE.convertTo( PowerUnits.RF, getAEMaxPower( is ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -10,11 +10,11 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
import appeng.api.implementations.items.IAEWrench;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
import appeng.util.Platform;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
|
||||
@Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraftAPI|core")
|
||||
@Interface(iface = "buildcraft.api.tools.IToolWrench", iname = "BC")
|
||||
public class ToolQuartzWrench extends AEBaseItem implements IAEWrench, IToolWrench
|
||||
{
|
||||
|
||||
|
|
|
@ -50,17 +50,17 @@ import appeng.me.storage.MEMonitorIInventory;
|
|||
import appeng.parts.automation.PartUpgradeable;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
import appeng.transformer.annotations.integration.Method;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.prioitylist.FuzzyPriorityList;
|
||||
import appeng.util.prioitylist.PrecisePriorityList;
|
||||
import buildcraft.api.transport.IPipeConnection;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@Interface(modid = "BuildCraft|Transport", iface = "buildcraft.api.transport.IPipeConnection")
|
||||
@Interface(iname = "BC", iface = "buildcraft.api.transport.IPipeConnection")
|
||||
public class PartStorageBus extends PartUpgradeable implements IGridTickable, ICellContainer, IMEMonitorHandlerReceiver<IAEItemStack>, IPipeConnection,
|
||||
IPriorityHost
|
||||
{
|
||||
|
@ -405,7 +405,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
|||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "BuildCraft|Transport")
|
||||
@Method(iname = "BC")
|
||||
public ConnectOverride overridePipeConnection(PipeType type, ForgeDirection with)
|
||||
{
|
||||
return type == PipeType.ITEM && with == side ? ConnectOverride.CONNECT : ConnectOverride.DISCONNECT;
|
||||
|
|
|
@ -14,18 +14,19 @@ import appeng.api.networking.ticking.IGridTickable;
|
|||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.cache.helpers.TunnelCollection;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|core")
|
||||
@Interface(iface = "buildcraft.api.power.IPowerReceptor", iname = "BC")
|
||||
public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPowerReceptor, IGridTickable
|
||||
{
|
||||
|
||||
|
@ -38,6 +39,10 @@ public class PartP2PBCPower extends PartP2PTunnel<PartP2PBCPower> implements IPo
|
|||
|
||||
public PartP2PBCPower(ItemStack is) {
|
||||
super( is );
|
||||
|
||||
if ( !AppEng.instance.isIntegrationEnabled( "MJ" ) )
|
||||
throw new RuntimeException( "MJ Not installed!" );
|
||||
|
||||
pp = new PowerHandler( this, Type.MACHINE );
|
||||
pp.configure( 1f, 320f, 800f, 640f );
|
||||
}
|
||||
|
|
|
@ -9,16 +9,17 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.config.TunnelType;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.cache.helpers.TunnelCollection;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
import appeng.transformer.annotations.integration.InterfaceList;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
import cpw.mods.fml.common.Optional.InterfaceList;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@InterfaceList(value = { @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"),
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "IC2") })
|
||||
@InterfaceList(value = { @Interface(iface = "ic2.api.energy.tile.IEnergySink", iname = "IC2"),
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySource", iname = "IC2") })
|
||||
public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements ic2.api.energy.tile.IEnergySink, ic2.api.energy.tile.IEnergySource
|
||||
{
|
||||
|
||||
|
@ -29,6 +30,9 @@ public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements i
|
|||
|
||||
public PartP2PIC2Power(ItemStack is) {
|
||||
super( is );
|
||||
|
||||
if ( !AppEng.instance.isIntegrationEnabled( "IC2" ) )
|
||||
throw new RuntimeException( "IC2 Not installed!" );
|
||||
}
|
||||
|
||||
double OutputPacket;
|
||||
|
|
|
@ -22,18 +22,18 @@ import appeng.integration.abstraction.IBC;
|
|||
import appeng.me.GridAccessException;
|
||||
import appeng.me.cache.helpers.TunnelCollection;
|
||||
import appeng.tile.inventory.AppEngNullInventory;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
import appeng.transformer.annotations.integration.Method;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.WrapperBCPipe;
|
||||
import appeng.util.inv.WrapperChainedInventory;
|
||||
import appeng.util.inv.WrapperMCISidedInventory;
|
||||
import buildcraft.api.transport.IPipeConnection;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@Interface(iface = "buildcraft.api.transport.IPipeConnection", modid = "BuildCraftAPI|transport")
|
||||
@Interface(iface = "buildcraft.api.transport.IPipeConnection", iname = "BC")
|
||||
public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeConnection, IInventory, ISidedInventory
|
||||
{
|
||||
|
||||
|
@ -324,7 +324,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
|||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "BuildCraftAPI|transport")
|
||||
@Method(iname = "BC")
|
||||
public ConnectOverride overridePipeConnection(PipeType type, ForgeDirection with)
|
||||
{
|
||||
return side.equals( with ) && type == PipeType.ITEM ? ConnectOverride.CONNECT : ConnectOverride.DEFAULT;
|
||||
|
|
|
@ -78,7 +78,7 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
|
|||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getTypeTexture()
|
||||
{
|
||||
return Blocks.diamond_block.getBlockTextureFromSide( 0 );
|
||||
return Blocks.lapis_block.getBlockTextureFromSide( 0 );
|
||||
}
|
||||
|
||||
List<PartP2PLiquids> getOutputs(Fluid input)
|
||||
|
|
|
@ -33,8 +33,8 @@ import appeng.parts.CableBusContainer;
|
|||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.transformer.annotations.integration.Method;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
|
||||
public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomCollision
|
||||
{
|
||||
|
@ -266,14 +266,14 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
|||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "MineFactoryReloaded")
|
||||
@Method(iname = "MFR")
|
||||
public RedNetConnectionType getConnectionType(World world, int x, int y, int z, ForgeDirection side)
|
||||
{
|
||||
return cb.canConnectRedstone( EnumSet.of( side ) ) ? RedNetConnectionType.CableSingle : RedNetConnectionType.None;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "MineFactoryReloaded")
|
||||
@Method(iname = "MFR")
|
||||
public int[] getOutputValues(World world, int x, int y, int z, ForgeDirection side)
|
||||
{
|
||||
// never called!
|
||||
|
@ -281,7 +281,7 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
|||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "MineFactoryReloaded")
|
||||
@Method(iname = "MFR")
|
||||
public int getOutputValue(World world, int x, int y, int z, ForgeDirection side, int subnet)
|
||||
{
|
||||
// never called!
|
||||
|
@ -289,14 +289,14 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
|||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "MineFactoryReloaded")
|
||||
@Method(iname = "MFR")
|
||||
public void onInputsChanged(World world, int x, int y, int z, ForgeDirection side, int[] inputValues)
|
||||
{
|
||||
// never called!
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "MineFactoryReloaded")
|
||||
@Method(iname = "MFR")
|
||||
public void onInputChanged(World world, int x, int y, int z, ForgeDirection side, int inputValue)
|
||||
{
|
||||
// never called!
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package appeng.tile.powersink;
|
||||
|
||||
public abstract class AEBasePoweredTile extends ThermalExpansion
|
||||
public abstract class AEBasePoweredTile extends RedstoneFlux
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -9,11 +9,11 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
import appeng.api.config.PowerUnits;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.integration.abstraction.IIC2;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
|
||||
@Interface(modid = "IC2", iface = "ic2.api.energy.tile.IEnergySink")
|
||||
public abstract class IC2 extends BuildCraft implements IEnergySink
|
||||
@Interface(iname = "IC2", iface = "ic2.api.energy.tile.IEnergySink")
|
||||
public abstract class IC2 extends MinecraftJoules implements IEnergySink
|
||||
{
|
||||
|
||||
boolean isInIC2 = false;
|
||||
|
|
|
@ -1,71 +1,71 @@
|
|||
package appeng.tile.powersink;
|
||||
|
||||
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.helpers.BaseMJperdition;
|
||||
import appeng.util.Platform;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
|
||||
@Interface(modid = "BuildCraftAPI|power", iface = "buildcraft.api.power.IPowerReceptor")
|
||||
public abstract class BuildCraft extends AERootPoweredTile implements IPowerReceptor
|
||||
{
|
||||
|
||||
BaseMJperdition bcPowerWrapper;
|
||||
|
||||
public BuildCraft() {
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( AppEng.instance.isIntegrationEnabled( "MJ" ) )
|
||||
{
|
||||
IMJ mjIntegration = (IMJ) AppEng.instance.getIntegration( "MJ" );
|
||||
if ( mjIntegration != null )
|
||||
{
|
||||
addNewHandler( bcPowerWrapper = mjIntegration.createPerdition( this ) );
|
||||
if ( bcPowerWrapper != null )
|
||||
bcPowerWrapper.configure( 1, 380, 1.0f / 5.0f, 1000 );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
// ignore.. no bc?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "BuildCraftAPI|power")
|
||||
final public PowerReceiver getPowerReceiver(ForgeDirection side)
|
||||
{
|
||||
if ( internalCanAcceptPower && getPowerSides().contains( side ) && bcPowerWrapper != null )
|
||||
return bcPowerWrapper.getPowerReceiver();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "BuildCraftAPI|power")
|
||||
final public void doWork(PowerHandler workProvider)
|
||||
{
|
||||
float requred = (float) getExternalPowerDemand( PowerUnits.MJ );
|
||||
double failed = injectExternalPower( PowerUnits.MJ, bcPowerWrapper.useEnergy( 0.0f, requred, true ) );
|
||||
if ( failed > 0.01 )
|
||||
bcPowerWrapper.addEnergy( (float) failed );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "BuildCraftAPI|power")
|
||||
final public World getWorld()
|
||||
{
|
||||
return worldObj;
|
||||
}
|
||||
|
||||
}
|
||||
package appeng.tile.powersink;
|
||||
|
||||
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.helpers.BaseMJperdition;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
import appeng.transformer.annotations.integration.Method;
|
||||
import appeng.util.Platform;
|
||||
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
|
||||
{
|
||||
|
||||
BaseMJperdition bcPowerWrapper;
|
||||
|
||||
public MinecraftJoules() {
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( AppEng.instance.isIntegrationEnabled( "MJ" ) )
|
||||
{
|
||||
IMJ mjIntegration = (IMJ) AppEng.instance.getIntegration( "MJ" );
|
||||
if ( mjIntegration != null )
|
||||
{
|
||||
addNewHandler( bcPowerWrapper = (BaseMJperdition) mjIntegration.createPerdition( this ) );
|
||||
if ( bcPowerWrapper != null )
|
||||
bcPowerWrapper.configure( 1, 380, 1.0f / 5.0f, 1000 );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
// ignore.. no bc?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(iname = "BC")
|
||||
final public PowerReceiver getPowerReceiver(ForgeDirection side)
|
||||
{
|
||||
if ( internalCanAcceptPower && getPowerSides().contains( side ) && bcPowerWrapper != null )
|
||||
return bcPowerWrapper.getPowerReceiver();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(iname = "BC")
|
||||
final public void doWork(PowerHandler workProvider)
|
||||
{
|
||||
float requred = (float) getExternalPowerDemand( PowerUnits.MJ );
|
||||
double failed = injectExternalPower( PowerUnits.MJ, bcPowerWrapper.useEnergy( 0.0f, requred, true ) );
|
||||
if ( failed > 0.01 )
|
||||
bcPowerWrapper.addEnergy( (float) failed );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(iname = "BC")
|
||||
final public World getWorld()
|
||||
{
|
||||
return worldObj;
|
||||
}
|
||||
|
||||
}
|
|
@ -2,11 +2,11 @@ package appeng.tile.powersink;
|
|||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
|
||||
@Interface(modid = "ThermalExpansion", iface = "cofh.api.energy.IEnergyHandler")
|
||||
public abstract class ThermalExpansion extends RotaryCraft implements IEnergyHandler
|
||||
@Interface(iname = "RF", iface = "cofh.api.energy.IEnergyHandler")
|
||||
public abstract class RedstoneFlux extends RotaryCraft implements IEnergyHandler
|
||||
{
|
||||
|
||||
@Override
|
|
@ -5,10 +5,10 @@ import Reika.RotaryCraft.API.ShaftPowerReceiver;
|
|||
import appeng.api.config.PowerUnits;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
|
||||
@Interface(modid = "RotaryCraft", iface = "Reika.RotaryCraft.API.ShaftPowerReceiver")
|
||||
@Interface(iname = "RotaryCraft", iface = "Reika.RotaryCraft.API.ShaftPowerReceiver")
|
||||
public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver
|
||||
{
|
||||
|
||||
|
|
|
@ -19,14 +19,12 @@ import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
|
|||
public class AppEngCore extends DummyModContainer implements IFMLLoadingPlugin
|
||||
{
|
||||
|
||||
public final AppEngCore instance;
|
||||
|
||||
protected final ModMetadata md = new ModMetadata();
|
||||
|
||||
@EventHandler
|
||||
public void load(FMLInitializationEvent event)
|
||||
{
|
||||
}
|
||||
|
||||
public AppEngCore() {
|
||||
instance = this;
|
||||
FMLRelaunchLog.info( "[AppEng] Core Init" );
|
||||
md.autogenerated = true;
|
||||
md.credits = "AlgorithmX2";
|
||||
|
@ -35,6 +33,11 @@ public class AppEngCore extends DummyModContainer implements IFMLLoadingPlugin
|
|||
md.name = getName();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void load(FMLInitializationEvent event)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerBus(EventBus bus, LoadController controller)
|
||||
{
|
||||
|
@ -44,7 +47,7 @@ public class AppEngCore extends DummyModContainer implements IFMLLoadingPlugin
|
|||
@Override
|
||||
public String[] getASMTransformerClass()
|
||||
{
|
||||
return null;//return new String[] { "appeng.transformer.AppEngASMTransformer" };
|
||||
return new String[] { "appeng.transformer.asm.ASMIntegration" };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -97,6 +100,6 @@ public class AppEngCore extends DummyModContainer implements IFMLLoadingPlugin
|
|||
@Override
|
||||
public String getAccessTransformerClass()
|
||||
{
|
||||
return "appeng.transformer.AppEngASMTransformer" ;
|
||||
return "appeng.transformer.asm.ASMTweaker";
|
||||
}
|
||||
}
|
||||
|
|
35
transformer/annotations/integration.java
Normal file
35
transformer/annotations/integration.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
package appeng.transformer.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
public @interface integration {
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface InterfaceList {
|
||||
|
||||
public Interface[] value();
|
||||
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface Interface {
|
||||
|
||||
public String iface();
|
||||
|
||||
public String iname();
|
||||
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface Method {
|
||||
|
||||
public String iname();
|
||||
|
||||
}
|
||||
}
|
212
transformer/asm/ASMIntegration.java
Normal file
212
transformer/asm/ASMIntegration.java
Normal file
|
@ -0,0 +1,212 @@
|
|||
package appeng.transformer.asm;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.tree.AnnotationNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationSide;
|
||||
import appeng.transformer.annotations.integration;
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
|
||||
public class ASMIntegration implements IClassTransformer
|
||||
{
|
||||
|
||||
private IntegrationRegistry integrationModules = new IntegrationRegistry();
|
||||
|
||||
public ASMIntegration() {
|
||||
|
||||
/**
|
||||
* Side, Display Name, ModID ClassPostFix
|
||||
*/
|
||||
|
||||
integrationModules.add( IntegrationSide.BOTH, "Rotary Craft", "RotaryCraft", "RotaryCraft" );
|
||||
integrationModules.add( IntegrationSide.BOTH, "Industrial Craft 2", "IC2", "IC2" );
|
||||
// integrationModules.add( IntegrationSide.BOTH, "Railcraft", "Railcraft", "RC" );
|
||||
// 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, "RedstoneFlux Power", null, "RF" );
|
||||
// integrationModules.add( IntegrationSide.BOTH, "Greg Tech", "gregtech_addon", "GT" );
|
||||
// integrationModules.add( IntegrationSide.BOTH, "Universal Electricity", null, "UE" );
|
||||
// integrationModules.add( IntegrationSide.BOTH, "Logistics Pipes", "LogisticsPipes|Main", "LP" );
|
||||
// integrationModules.add( IntegrationSide.CLIENT, "Inventory Tweaks", "", "InvTweaks" );
|
||||
integrationModules.add( IntegrationSide.BOTH, "Mine Factory Reloaded", "MineFactoryReloaded", "MFR" );
|
||||
integrationModules.add( IntegrationSide.BOTH, "Deep Storage Unit", null, "DSU" );
|
||||
// integrationModules.add( IntegrationSide.BOTH, "Better Storage", "betterstorage" );
|
||||
integrationModules.add( IntegrationSide.BOTH, "Factorization", "factorization", "FZ" );
|
||||
// integrationModules.add( IntegrationSide.BOTH, "Forestry", "Forestry", "Forestry" );
|
||||
// integrationModules.add( IntegrationSide.BOTH, "Mekanism", "Mekanism", "Mekanism" );
|
||||
integrationModules.add( IntegrationSide.CLIENT, "Waila", "Waila", "Waila" );
|
||||
integrationModules.add( IntegrationSide.BOTH, "Rotatable Blocks", "RotatableBlocks", "RB" );
|
||||
integrationModules.add( IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks", "InvTweaks" );
|
||||
integrationModules.add( IntegrationSide.CLIENT, "Not Enough Items", "NotEnoughItems", "NEI" );
|
||||
integrationModules.add( IntegrationSide.CLIENT, "Craft Guide", "craftguide", "CraftGuide" );
|
||||
integrationModules.add( IntegrationSide.BOTH, "Forge MultiPart", "McMultipart", "FMP" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass)
|
||||
{
|
||||
if ( transformedName.startsWith( "appeng.transformer" ) )
|
||||
return basicClass;
|
||||
|
||||
if ( transformedName.startsWith( "appeng." ) )
|
||||
{
|
||||
// log( "Found " + transformedName );
|
||||
|
||||
ClassNode classNode = new ClassNode();
|
||||
ClassReader classReader = new ClassReader( basicClass );
|
||||
classReader.accept( classNode, 0 );
|
||||
|
||||
try
|
||||
{
|
||||
boolean reWrite = removeOptionals( classNode );
|
||||
|
||||
if ( reWrite )
|
||||
{
|
||||
ClassWriter writer = new ClassWriter( ClassWriter.COMPUTE_MAXS );
|
||||
classNode.accept( writer );
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
private boolean removeOptionals(ClassNode classNode)
|
||||
{
|
||||
boolean changed = false;
|
||||
|
||||
if ( classNode.visibleAnnotations != null )
|
||||
{
|
||||
for (AnnotationNode an : classNode.visibleAnnotations)
|
||||
{
|
||||
if ( hasAnnotation( an, integration.Interface.class ) )
|
||||
{
|
||||
if ( stripInterface( classNode, integration.Interface.class, an ) )
|
||||
changed = true;
|
||||
}
|
||||
else if ( hasAnnotation( an, integration.InterfaceList.class ) )
|
||||
{
|
||||
for (Object o : ((List) an.values.get( 1 )))
|
||||
{
|
||||
if ( stripInterface( classNode, integration.InterfaceList.class, (AnnotationNode) o ) )
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<MethodNode> i = classNode.methods.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
MethodNode mn = i.next();
|
||||
|
||||
if ( mn.visibleAnnotations != null )
|
||||
{
|
||||
for (AnnotationNode an : mn.visibleAnnotations)
|
||||
{
|
||||
if ( hasAnnotation( an, integration.Method.class ) )
|
||||
{
|
||||
if ( stripMethod( classNode, mn, i, integration.Method.class, an ) )
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( changed )
|
||||
log( "Updated " + classNode.name );
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
private boolean hasAnnotation(AnnotationNode ann, Class anno)
|
||||
{
|
||||
return ann.desc.equals( Type.getDescriptor( anno ) );
|
||||
}
|
||||
|
||||
private boolean stripMethod(ClassNode classNode, MethodNode mn, Iterator<MethodNode> i, Class class1, AnnotationNode an)
|
||||
{
|
||||
if ( an.values.size() != 2 )
|
||||
throw new RuntimeException( "Unable to handle Method annotation on " + classNode.name );
|
||||
|
||||
String iName = null;
|
||||
|
||||
if ( an.values.get( 0 ).equals( "iname" ) )
|
||||
iName = (String) an.values.get( 1 );
|
||||
|
||||
if ( iName != null )
|
||||
{
|
||||
if ( !IntegrationRegistry.instance.isEnabled( iName ) )
|
||||
{
|
||||
log( "Removing Method " + mn.name + " from " + classNode.name + " because " + iName + " integration is disabled." );
|
||||
i.remove();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
log( "Allowing Method " + mn.name + " from " + classNode.name + " because " + iName + " integration is enabled." );
|
||||
}
|
||||
else
|
||||
throw new RuntimeException( "Unable to handle Method annotation on " + classNode.name );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean stripInterface(ClassNode classNode, Class class1, AnnotationNode an)
|
||||
{
|
||||
if ( an.values.size() != 4 )
|
||||
throw new RuntimeException( "Unable to handle Interface annotation on " + classNode.name );
|
||||
|
||||
String iFace = null;
|
||||
String iName = null;
|
||||
|
||||
if ( an.values.get( 0 ).equals( "iface" ) )
|
||||
iFace = (String) an.values.get( 1 );
|
||||
else if ( an.values.get( 2 ).equals( "iface" ) )
|
||||
iFace = (String) an.values.get( 3 );
|
||||
|
||||
if ( an.values.get( 0 ).equals( "iname" ) )
|
||||
iName = (String) an.values.get( 1 );
|
||||
else if ( an.values.get( 2 ).equals( "iname" ) )
|
||||
iName = (String) an.values.get( 3 );
|
||||
|
||||
if ( iName != null && iFace != null )
|
||||
{
|
||||
if ( !IntegrationRegistry.instance.isEnabled( iName ) )
|
||||
{
|
||||
log( "Removing Interface " + iFace + " from " + classNode.name + " because " + iName + " integration is disabled." );
|
||||
classNode.interfaces.remove( iFace.replace( '.', '/' ) );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
log( "Allowing Interface " + iFace + " from " + classNode.name + " because " + iName + " integration is enabled." );
|
||||
}
|
||||
else
|
||||
throw new RuntimeException( "Unable to handle Method annotation on " + classNode.name );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void log(String string)
|
||||
{
|
||||
FMLRelaunchLog.log( "AE2-CORE", Level.INFO, string );
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package appeng.transformer;
|
||||
package appeng.transformer.asm;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
|
@ -20,12 +20,12 @@ import com.google.common.collect.Multimap;
|
|||
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
|
||||
public class AppEngASMTransformer implements IClassTransformer
|
||||
public class ASMTweaker implements IClassTransformer
|
||||
{
|
||||
|
||||
Multimap<String, String> privateToPublicMethods = HashMultimap.create();
|
||||
|
||||
public AppEngASMTransformer() {
|
||||
public ASMTweaker() {
|
||||
privateToPublicMethods.put( "net.minecraft.client.gui.inventory.GuiContainer", "func_146977_a" );
|
||||
privateToPublicMethods.put( "net.minecraft.client.gui.inventory.GuiContainer", "a" );
|
||||
}
|
Loading…
Reference in a new issue