From 028555bc8a38f80b11406cc19e24f00633069eb2 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 5 Apr 2014 21:50:01 -0500 Subject: [PATCH 1/5] Fixed Fluid Render. --- parts/p2p/PartP2PLiquids.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parts/p2p/PartP2PLiquids.java b/parts/p2p/PartP2PLiquids.java index 6f86e0f7..22a8c39a 100644 --- a/parts/p2p/PartP2PLiquids.java +++ b/parts/p2p/PartP2PLiquids.java @@ -78,7 +78,7 @@ public class PartP2PLiquids extends PartP2PTunnel implements IFl @SideOnly(Side.CLIENT) public IIcon getTypeTexture() { - return Blocks.diamond_block.getBlockTextureFromSide( 0 ); + return Blocks.lapis_block.getBlockTextureFromSide( 0 ); } List getOutputs(Fluid input) From 97c06db6efcf520cf65740b28e85ba2f417550e7 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sun, 6 Apr 2014 01:51:44 -0500 Subject: [PATCH 2/5] Use ordinal of parts/items as the default meta, allows for holes in the setup but lets default configs be consistent regardless of other mods. --- core/AEConfig.java | 38 +++++++++++++++++++++++-------- items/materials/ItemMaterial.java | 2 +- items/parts/ItemPart.java | 2 +- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/core/AEConfig.java b/core/AEConfig.java index 3e48dd90..901850ea 100644 --- a/core/AEConfig.java +++ b/core/AEConfig.java @@ -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 diff --git a/items/materials/ItemMaterial.java b/items/materials/ItemMaterial.java index ef495e57..f669bab3 100644 --- a/items/materials/ItemMaterial.java +++ b/items/materials/ItemMaterial.java @@ -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 ); diff --git a/items/parts/ItemPart.java b/items/parts/ItemPart.java index d12027dd..85e26169 100644 --- a/items/parts/ItemPart.java +++ b/items/parts/ItemPart.java @@ -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(); From 5248eeeace16c30ebc1e3369a25d0321ec4c411f Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sun, 6 Apr 2014 01:55:24 -0500 Subject: [PATCH 3/5] Switched from FML Optional to AE Optional, lets me specify more interesting requirements for integration, and lets the config alter the resulting integration setup. --- core/AppEng.java | 38 +--- helpers/AEMultiTile.java | 4 +- integration/IntegrationNode.java | 8 +- integration/IntegrationRegistry.java | 63 +----- integration/abstraction/IMJ.java | 5 +- .../abstraction/helpers/BaseMJperdition.java | 4 +- integration/modules/BC.java | 10 +- integration/modules/IC2.java | 8 +- integration/modules/MFR.java | 27 +++ integration/modules/MJ.java | 11 +- integration/modules/RF.java | 27 +++ integration/modules/RotaryCraft.java | 26 +++ integration/modules/dead/TE.java | 7 +- items/tools/ToolNetworkTool.java | 4 +- .../powered/powersink/AEBasePoweredItem.java | 2 +- items/tools/powered/powersink/IC2.java | 4 +- ...hermalExpansion.java => RedstoneFlux.java} | 80 +++---- items/tools/quartz/ToolQuartzWrench.java | 4 +- parts/misc/PartStorageBus.java | 8 +- parts/p2p/PartP2PBCPower.java | 9 +- parts/p2p/PartP2PIC2Power.java | 12 +- parts/p2p/PartP2PItems.java | 8 +- tile/networking/TileCableBus.java | 12 +- tile/powersink/AEBasePoweredTile.java | 2 +- tile/powersink/IC2.java | 6 +- .../{BuildCraft.java => MinecraftJoules.java} | 142 ++++++------- ...hermalExpansion.java => RedstoneFlux.java} | 6 +- tile/powersink/RotaryCraft.java | 4 +- transformer/AppEngCore.java | 17 +- transformer/annotations/integration.java | 35 ++++ transformer/asm/ASMIntegration.java | 198 ++++++++++++++++++ .../ASMTweaker.java} | 6 +- 32 files changed, 526 insertions(+), 271 deletions(-) create mode 100644 integration/modules/MFR.java create mode 100644 integration/modules/RF.java create mode 100644 integration/modules/RotaryCraft.java rename items/tools/powered/powersink/{ThermalExpansion.java => RedstoneFlux.java} (72%) rename tile/powersink/{BuildCraft.java => MinecraftJoules.java} (73%) rename tile/powersink/{ThermalExpansion.java => RedstoneFlux.java} (85%) create mode 100644 transformer/annotations/integration.java create mode 100644 transformer/asm/ASMIntegration.java rename transformer/{AppEngASMTransformer.java => asm/ASMTweaker.java} (96%) diff --git a/core/AppEng.java b/core/AppEng.java index f6b5fb01..62ba2392 100644 --- a/core/AppEng.java +++ b/core/AppEng.java @@ -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) @@ -153,7 +123,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 )" ); } @@ -165,7 +135,7 @@ public class AppEng AELog.info( "PostInit" ); Registration.instance.PostInit( event ); - integrationModules.postinit(); + IntegrationRegistry.instance.postinit(); AEConfig.instance.save(); diff --git a/helpers/AEMultiTile.java b/helpers/AEMultiTile.java index a980de44..9d6f6478 100644 --- a/helpers/AEMultiTile.java +++ b/helpers/AEMultiTile.java @@ -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 { diff --git a/integration/IntegrationNode.java b/integration/IntegrationNode.java index 24bd7d6d..6532fb1a 100644 --- a/integration/IntegrationNode.java +++ b/integration/IntegrationNode.java @@ -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; } diff --git a/integration/IntegrationRegistry.java b/integration/IntegrationRegistry.java index 1a936887..529a1d65 100644 --- a/integration/IntegrationRegistry.java +++ b/integration/IntegrationRegistry.java @@ -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 modules = new LinkedList(); - 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() diff --git a/integration/abstraction/IMJ.java b/integration/abstraction/IMJ.java index cd75d37a..732ab938 100644 --- a/integration/abstraction/IMJ.java +++ b/integration/abstraction/IMJ.java @@ -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); } diff --git a/integration/abstraction/helpers/BaseMJperdition.java b/integration/abstraction/helpers/BaseMJperdition.java index 00d6caed..3d6d04bf 100644 --- a/integration/abstraction/helpers/BaseMJperdition.java +++ b/integration/abstraction/helpers/BaseMJperdition.java @@ -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); diff --git a/integration/modules/BC.java b/integration/modules/BC.java index 5afc2e47..4a451403 100644 --- a/integration/modules/BC.java +++ b/integration/modules/BC.java @@ -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() ); diff --git a/integration/modules/IC2.java b/integration/modules/IC2.java index ed9637e6..5a4182de 100644 --- a/integration/modules/IC2.java +++ b/integration/modules/IC2.java @@ -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 diff --git a/integration/modules/MFR.java b/integration/modules/MFR.java new file mode 100644 index 00000000..510e2adf --- /dev/null +++ b/integration/modules/MFR.java @@ -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 + { + + } + +} diff --git a/integration/modules/MJ.java b/integration/modules/MJ.java index 5b851765..f9d0b7ec 100644 --- a/integration/modules/MJ.java +++ b/integration/modules/MJ.java @@ -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 { - } } diff --git a/integration/modules/RF.java b/integration/modules/RF.java new file mode 100644 index 00000000..375d6e97 --- /dev/null +++ b/integration/modules/RF.java @@ -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() + { + + } + +} diff --git a/integration/modules/RotaryCraft.java b/integration/modules/RotaryCraft.java new file mode 100644 index 00000000..200df1be --- /dev/null +++ b/integration/modules/RotaryCraft.java @@ -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 + { + + } + +} diff --git a/integration/modules/dead/TE.java b/integration/modules/dead/TE.java index febd07d2..e5f08662 100644 --- a/integration/modules/dead/TE.java +++ b/integration/modules/dead/TE.java @@ -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 } diff --git a/items/tools/ToolNetworkTool.java b/items/tools/ToolNetworkTool.java index 18f18974..802e171f 100644 --- a/items/tools/ToolNetworkTool.java +++ b/items/tools/ToolNetworkTool.java @@ -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 { diff --git a/items/tools/powered/powersink/AEBasePoweredItem.java b/items/tools/powered/powersink/AEBasePoweredItem.java index d5a0650e..7e46b501 100644 --- a/items/tools/powered/powersink/AEBasePoweredItem.java +++ b/items/tools/powered/powersink/AEBasePoweredItem.java @@ -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) { diff --git a/items/tools/powered/powersink/IC2.java b/items/tools/powered/powersink/IC2.java index 0bddec1c..5b8c84e1 100644 --- a/items/tools/powered/powersink/IC2.java +++ b/items/tools/powered/powersink/IC2.java @@ -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 { diff --git a/items/tools/powered/powersink/ThermalExpansion.java b/items/tools/powered/powersink/RedstoneFlux.java similarity index 72% rename from items/tools/powered/powersink/ThermalExpansion.java rename to items/tools/powered/powersink/RedstoneFlux.java index e1160ffb..d2f0f843 100644 --- a/items/tools/powered/powersink/ThermalExpansion.java +++ b/items/tools/powered/powersink/RedstoneFlux.java @@ -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 ) ); + } + +} diff --git a/items/tools/quartz/ToolQuartzWrench.java b/items/tools/quartz/ToolQuartzWrench.java index 7f96a00f..2ea7142d 100644 --- a/items/tools/quartz/ToolQuartzWrench.java +++ b/items/tools/quartz/ToolQuartzWrench.java @@ -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 { diff --git a/parts/misc/PartStorageBus.java b/parts/misc/PartStorageBus.java index 105a75f1..e54a5a49 100644 --- a/parts/misc/PartStorageBus.java +++ b/parts/misc/PartStorageBus.java @@ -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, 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; diff --git a/parts/p2p/PartP2PBCPower.java b/parts/p2p/PartP2PBCPower.java index 5a8c67e1..31ddc908 100644 --- a/parts/p2p/PartP2PBCPower.java +++ b/parts/p2p/PartP2PBCPower.java @@ -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 implements IPowerReceptor, IGridTickable { @@ -38,6 +39,10 @@ public class PartP2PBCPower extends PartP2PTunnel 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 ); } diff --git a/parts/p2p/PartP2PIC2Power.java b/parts/p2p/PartP2PIC2Power.java index 3da4dbf0..17002250 100644 --- a/parts/p2p/PartP2PIC2Power.java +++ b/parts/p2p/PartP2PIC2Power.java @@ -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 implements ic2.api.energy.tile.IEnergySink, ic2.api.energy.tile.IEnergySource { @@ -29,6 +30,9 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i public PartP2PIC2Power(ItemStack is) { super( is ); + + if ( !AppEng.instance.isIntegrationEnabled( "IC2" ) ) + throw new RuntimeException( "IC2 Not installed!" ); } double OutputPacket; diff --git a/parts/p2p/PartP2PItems.java b/parts/p2p/PartP2PItems.java index 863f68ff..e5601b76 100644 --- a/parts/p2p/PartP2PItems.java +++ b/parts/p2p/PartP2PItems.java @@ -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 implements IPipeConnection, IInventory, ISidedInventory { @@ -324,7 +324,7 @@ public class PartP2PItems extends PartP2PTunnel 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; diff --git a/tile/networking/TileCableBus.java b/tile/networking/TileCableBus.java index 56116fab..5f23133c 100644 --- a/tile/networking/TileCableBus.java +++ b/tile/networking/TileCableBus.java @@ -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! diff --git a/tile/powersink/AEBasePoweredTile.java b/tile/powersink/AEBasePoweredTile.java index 820875d0..e656172f 100644 --- a/tile/powersink/AEBasePoweredTile.java +++ b/tile/powersink/AEBasePoweredTile.java @@ -1,6 +1,6 @@ package appeng.tile.powersink; -public abstract class AEBasePoweredTile extends ThermalExpansion +public abstract class AEBasePoweredTile extends RedstoneFlux { } diff --git a/tile/powersink/IC2.java b/tile/powersink/IC2.java index a1cce02d..63dc98b8 100644 --- a/tile/powersink/IC2.java +++ b/tile/powersink/IC2.java @@ -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; diff --git a/tile/powersink/BuildCraft.java b/tile/powersink/MinecraftJoules.java similarity index 73% rename from tile/powersink/BuildCraft.java rename to tile/powersink/MinecraftJoules.java index d879e6b5..c1bd9538 100644 --- a/tile/powersink/BuildCraft.java +++ b/tile/powersink/MinecraftJoules.java @@ -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; + } + +} diff --git a/tile/powersink/ThermalExpansion.java b/tile/powersink/RedstoneFlux.java similarity index 85% rename from tile/powersink/ThermalExpansion.java rename to tile/powersink/RedstoneFlux.java index 4271734e..a2ac0e8f 100644 --- a/tile/powersink/ThermalExpansion.java +++ b/tile/powersink/RedstoneFlux.java @@ -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 diff --git a/tile/powersink/RotaryCraft.java b/tile/powersink/RotaryCraft.java index 29f15cec..8b7ecfee 100644 --- a/tile/powersink/RotaryCraft.java +++ b/tile/powersink/RotaryCraft.java @@ -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 { diff --git a/transformer/AppEngCore.java b/transformer/AppEngCore.java index 6be5e740..e70f3b70 100644 --- a/transformer/AppEngCore.java +++ b/transformer/AppEngCore.java @@ -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"; } } diff --git a/transformer/annotations/integration.java b/transformer/annotations/integration.java new file mode 100644 index 00000000..6b10a6a8 --- /dev/null +++ b/transformer/annotations/integration.java @@ -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(); + + } +} diff --git a/transformer/asm/ASMIntegration.java b/transformer/asm/ASMIntegration.java new file mode 100644 index 00000000..2ab23d9e --- /dev/null +++ b/transformer/asm/ASMIntegration.java @@ -0,0 +1,198 @@ +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 ) ) + { + changed = changed || stripInterface( classNode, integration.Interface.class, an ); + } + else if ( hasAnnotation( an, integration.InterfaceList.class ) ) + { + for (Object o : ((List) an.values.get( 1 ))) + changed = changed || stripInterface( classNode, integration.InterfaceList.class, (AnnotationNode) o ); + } + } + } + + Iterator 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 ) ) + { + changed = changed || stripMethod( classNode, mn, i, integration.Method.class, an ); + } + } + + } + } + + return changed; + } + + private boolean hasAnnotation(AnnotationNode ann, Class anno) + { + return ann.desc.equals( Type.getDescriptor( anno ) ); + } + + private boolean stripMethod(ClassNode classNode, MethodNode mn, Iterator 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(); + } + } + 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 ); + } + } + 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 ); + } + +} diff --git a/transformer/AppEngASMTransformer.java b/transformer/asm/ASMTweaker.java similarity index 96% rename from transformer/AppEngASMTransformer.java rename to transformer/asm/ASMTweaker.java index b76dc882..95668642 100644 --- a/transformer/AppEngASMTransformer.java +++ b/transformer/asm/ASMTweaker.java @@ -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 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" ); } From 14f93f66f605e0bdf5b3ecc680d38168ab3937bb Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sun, 6 Apr 2014 03:20:30 -0500 Subject: [PATCH 4/5] Moved NEI Check to constructor. --- integration/modules/NEI.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/integration/modules/NEI.java b/integration/modules/NEI.java index 0285ec53..66545844 100644 --- a/integration/modules/NEI.java +++ b/integration/modules/NEI.java @@ -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 } ); From 72219780ef1f7d0e8f7d45fa83bfad92a18dcbca Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sun, 6 Apr 2014 03:20:51 -0500 Subject: [PATCH 5/5] AE Optional Transformer should not be fully operational. --- transformer/asm/ASMIntegration.java | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/transformer/asm/ASMIntegration.java b/transformer/asm/ASMIntegration.java index 2ab23d9e..7c47818d 100644 --- a/transformer/asm/ASMIntegration.java +++ b/transformer/asm/ASMIntegration.java @@ -98,12 +98,16 @@ public class ASMIntegration implements IClassTransformer { if ( hasAnnotation( an, integration.Interface.class ) ) { - changed = changed || stripInterface( classNode, integration.Interface.class, an ); + if ( stripInterface( classNode, integration.Interface.class, an ) ) + changed = true; } else if ( hasAnnotation( an, integration.InterfaceList.class ) ) { for (Object o : ((List) an.values.get( 1 ))) - changed = changed || stripInterface( classNode, integration.InterfaceList.class, (AnnotationNode) o ); + { + if ( stripInterface( classNode, integration.InterfaceList.class, (AnnotationNode) o ) ) + changed = true; + } } } } @@ -119,13 +123,17 @@ public class ASMIntegration implements IClassTransformer { if ( hasAnnotation( an, integration.Method.class ) ) { - changed = changed || stripMethod( classNode, mn, i, integration.Method.class, an ); + if ( stripMethod( classNode, mn, i, integration.Method.class, an ) ) + changed = true; } } } } + if ( changed ) + log( "Updated " + classNode.name ); + return changed; } @@ -150,7 +158,10 @@ public class ASMIntegration implements IClassTransformer { 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 ); @@ -181,8 +192,11 @@ public class ASMIntegration implements IClassTransformer if ( !IntegrationRegistry.instance.isEnabled( iName ) ) { log( "Removing Interface " + iFace + " from " + classNode.name + " because " + iName + " integration is disabled." ); - classNode.interfaces.remove( iFace ); + 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 );