mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-10-25 20:32:32 +00:00
Tinkers Corestruct v0.0.1
Added initial release of preloader (thanks AlgorithmX2). Cleaned mcmod.info. Updated build.xml appropriately.
This commit is contained in:
1 parent
be979ef064
commit
8a10734932
7 files changed
+304
-6
No files matched your search
@@ -4,6 +4,9 @@ Modify all the things, then do it again!
|
||||
Melt down any metals you find.
|
||||
Turn everything into golems!
|
||||
|
||||
##Development
|
||||
Install Forge as usual, and setup your IDE as with any other Forge project. Forge Multipart must be installed to `forge/mcp/jars/mods/` from the [Forge file server](http://files.minecraftforge.net/ForgeMultipart/). Copy `TCore_dummy.jar` to `forge/mcp/jars/mods/` to enable the Preloader (optional -- only needed when working on the preloader itself)
|
||||
|
||||
##Compile from Source
|
||||
Run [Apache Ant](http://ant.apache.org/bindownload.cgi) in the repository root: `ant package`
|
||||
|
||||
|
||||
Binary file not shown.
@@ -24,22 +24,26 @@
|
||||
<property name="build.dependencies.file" value="${build.dir}/dependencies.properties" />
|
||||
<property name="ccl.version" value="1.0.0.36" />
|
||||
<property name="fmp.version" value="1.0.0.182" />
|
||||
|
||||
<property name="ccl.name" value="CodeChickenLib-dev-${mc.version}-${ccl.version}.jar" />
|
||||
<property name="fmp.name" value="ForgeMultipart-dev-${mc.version}-${fmp.version}.jar" />
|
||||
<available property="fmp-downloaded" file="${download.dir}/${fmp.name}" />
|
||||
<available property="ccl-downloaded" file="${download.dir}/${ccl.name}" />
|
||||
|
||||
<condition property="ccl-installed">
|
||||
<and>
|
||||
<isset property="forge-installed" />
|
||||
<equals arg1="${build.dependencies.ccl}" arg2="${ccl.version}" />
|
||||
</and>
|
||||
</condition>
|
||||
|
||||
<condition property="fmp-installed">
|
||||
<and>
|
||||
<isset property="forge-installed" />
|
||||
<equals arg1="${build.dependencies.fmp}" arg2="${fmp.version}" />
|
||||
</and>
|
||||
</condition>
|
||||
|
||||
<property name="version.major" value="0"/>
|
||||
<property name="version.minor" value="0"/>
|
||||
|
||||
@@ -65,6 +69,7 @@
|
||||
<target name="download-ccl" unless="ccl-downloaded">
|
||||
<get src="http://files.minecraftforge.net/CodeChickenLib/${ccl.name}" dest="${download.dir}" usetimestamp="true" />
|
||||
</target>
|
||||
|
||||
<target name="install-ccl" depends="setup,download-ccl" unless="ccl-installed">
|
||||
<echo message="Deleting old CodeChickenLib" />
|
||||
<delete file="${mcp.dir}/lib/${build.dependencies.ccl.name}" />
|
||||
@@ -78,6 +83,7 @@
|
||||
<entry key="ccl.name" value="${ccl.name}" />
|
||||
</propertyfile>
|
||||
</target>
|
||||
|
||||
<target name="install-fmp" depends="setup,download-fmp" unless="fmp-installed">
|
||||
<echo message="Deleting old ForgeMultipart" />
|
||||
<delete file="${mcp.dir}/lib/${build.dependencies.fmp.name}" />
|
||||
@@ -91,8 +97,8 @@
|
||||
<entry key="fmp.name" value="${fmp.name}" />
|
||||
</propertyfile>
|
||||
</target>
|
||||
<target name="install-deps" depends="install-ccl,install-fmp" />
|
||||
|
||||
<target name="install-deps" depends="install-ccl,install-fmp" />
|
||||
|
||||
<target name="download-fmp" unless="fmp-downloaded">
|
||||
<get src="http://files.minecraftforge.net/ForgeMultipart/${fmp.name}" dest="${download.dir}" usetimestamp="true" />
|
||||
@@ -205,8 +211,9 @@
|
||||
</exec>
|
||||
|
||||
<!-- Copy classes -->
|
||||
<copy todir="${classes.dir}">
|
||||
<fileset dir="${mcp.dir}/reobf/minecraft"/>
|
||||
<mkdir dir="${classes.dir}/tconstruct"/>
|
||||
<copy todir="${classes.dir}/tconstruct">
|
||||
<fileset dir="${mcp.dir}/reobf/minecraft/tconstruct"/>
|
||||
</copy>
|
||||
|
||||
<!-- Copy resources -->
|
||||
@@ -224,6 +231,7 @@
|
||||
<copy todir="${classes.dir}">
|
||||
<fileset dir="${resources.dir}">
|
||||
<exclude name="mcmod.info"/>
|
||||
<exclude name="PreloaderManifest.mf"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
@@ -241,7 +249,7 @@
|
||||
|
||||
<delete dir="${jar.dir}"/>
|
||||
<mkdir dir="${jar.dir}"/>
|
||||
<jar destfile="${jar.dir}/TConstruct-${mc.version}-${project.version.full}.jar" basedir="${classes.dir}"/>
|
||||
<jar destfile="${jar.dir}/TConstruct-${mc.version}-${project.version.full}.jar" basedir="${classes.dir}" manifest="${resources.dir}/PreloaderManifest.mf"/>
|
||||
|
||||
</target>
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
FMLCorePlugin: tconstruct.preloader.TConstructLoaderContainer
|
||||
FMLCorePluginContainsFMLMod: true
|
||||
+19
-2
@@ -16,6 +16,23 @@
|
||||
"parent":"",
|
||||
"dependencies": []
|
||||
},
|
||||
{
|
||||
"modid": "TConstruct-Preloader",
|
||||
"name": "Tinkers Corestruct",
|
||||
"description": "Preloader for Tinkers Construct",
|
||||
"version": "0.0.1",
|
||||
"mcversion": "@MCVERSION@",
|
||||
"url": "https://github.com/mDiyo/TinkersConstruct/tree/master/src/tconstruct/preloader",
|
||||
"updateUrl": "",
|
||||
"authors": [
|
||||
"AlgorithmX2", "Sunstrike"
|
||||
],
|
||||
"credits": "",
|
||||
"logoFile": "",
|
||||
"screenshots": [],
|
||||
"parent":"",
|
||||
"dependencies": []
|
||||
},
|
||||
{
|
||||
"modid": "TConstruct|CompatMineFactoryReloaded",
|
||||
"name": "TConstruct Compat: MFR",
|
||||
@@ -34,8 +51,8 @@
|
||||
"dependencies": [
|
||||
"TConstruct"
|
||||
]
|
||||
}
|
||||
{
|
||||
},
|
||||
{
|
||||
"modid": "TConstruct|CompatForgeMultiPart",
|
||||
"name": "TConstruct Compat: FMP",
|
||||
"description": "TConstruct support for forgemultipart",
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
package tconstruct.preloader;
|
||||
|
||||
/*
|
||||
* ASMInterfaceRepair is derived from code graciously provided by AlgorithmX2 of Applied Energistics.
|
||||
* The code was adapted for this loader by Sunstrike. Any queries should be directed to him, not AlgorithmX2.
|
||||
*/
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.signature.SignatureReader;
|
||||
import org.objectweb.asm.signature.SignatureVisitor;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class ASMInterfaceRepair implements IClassTransformer {
|
||||
|
||||
public static Map<String,Boolean> APIInterfaces = new HashMap<String, Boolean>();
|
||||
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] bytes)
|
||||
{
|
||||
if ( name.startsWith( "tconstruct." ) && ! name.startsWith( "tconstruct.preloader" ) )
|
||||
{
|
||||
ClassReader cr = new ClassReader(bytes);
|
||||
ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, 0);
|
||||
|
||||
boolean changed = false;
|
||||
|
||||
if ( this.verifyAPI(cn) )
|
||||
changed = true;
|
||||
|
||||
if ( changed )
|
||||
{
|
||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
cn.accept(cw);
|
||||
bytes = cw.toByteArray();
|
||||
log( "Altering definition of " + transformedName );
|
||||
}
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
private boolean isInternal( String path )
|
||||
{
|
||||
return path.startsWith( "java/" )
|
||||
|| path.startsWith( "cpw/mods/fml/" )
|
||||
|| path.startsWith( "tconstruct/" )
|
||||
|| path.startsWith( "com/google/" )
|
||||
|| path.startsWith( "net/minecraftforge/" )
|
||||
|| path.startsWith( "net/minecraft/" );
|
||||
}
|
||||
|
||||
private boolean isClassAvailable( String inf )
|
||||
{
|
||||
if ( APIInterfaces.containsKey( inf ) )
|
||||
return APIInterfaces.get( inf );
|
||||
|
||||
boolean isAvailable = false;
|
||||
Class obj = null;
|
||||
|
||||
try
|
||||
{
|
||||
obj = Class.forName( inf.replace( "/", "." ) );
|
||||
//obj = ReflectionHelper.getClass( getClass().getClassLoader(), inf.replace( "/", "." ) );
|
||||
}
|
||||
catch ( Throwable _ ) {}
|
||||
|
||||
// java.io.InputStream is = this.getClass().getResourceAsStream( "/" + inf + ".class" );
|
||||
APIInterfaces.put( inf, isAvailable = ( obj != null) );
|
||||
return isAvailable;
|
||||
}
|
||||
|
||||
class SigChecker extends SignatureVisitor {
|
||||
|
||||
private ASMInterfaceRepair asmTransformer;
|
||||
public boolean isAvailable = true;
|
||||
|
||||
public SigChecker(int api, ASMInterfaceRepair t) {
|
||||
super(api);
|
||||
asmTransformer = t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitInnerClassType(String name) {
|
||||
visitTypeVariable(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitClassType(String name) {
|
||||
visitTypeVariable(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTypeVariable(String className) {
|
||||
if ( isInternal( className ) ) return;
|
||||
isAvailable = isAvailable && asmTransformer.isClassAvailable( className );
|
||||
log( className + " is " + ( isAvailable ? "available" : "not available" ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean verifyAPI(ClassNode cn)
|
||||
{
|
||||
boolean changed = false;
|
||||
|
||||
//log( "Examining " + cn.name );
|
||||
|
||||
Iterator<MethodNode> mn = cn.methods.iterator();
|
||||
while ( mn.hasNext() )
|
||||
{
|
||||
MethodNode meth = mn.next();
|
||||
|
||||
SigChecker sc = new SigChecker(1,this);
|
||||
( new SignatureReader(meth.desc) ).accept( sc );
|
||||
|
||||
boolean isAvailable = sc.isAvailable;
|
||||
|
||||
if ( ! isAvailable )
|
||||
{
|
||||
mn.remove();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<String> i = cn.interfaces.iterator();
|
||||
while ( i.hasNext() )
|
||||
{
|
||||
String inf = i.next();
|
||||
|
||||
if ( isInternal( inf ) )
|
||||
continue;
|
||||
|
||||
boolean isAvailable = isClassAvailable( inf );
|
||||
log( inf + " is " + ( isAvailable ? "available" : "not available" ) );
|
||||
|
||||
if ( ! isAvailable )
|
||||
{
|
||||
i.remove();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
private void log(String string) {
|
||||
//TConstructLoaderContainer.logger.info( string );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package tconstruct.preloader;
|
||||
|
||||
/*
|
||||
* TConstructLoaderContainer is derived from code graciously provided by AlgorithmX2 of Applied Energistics.
|
||||
* The code was adapted for this loader by Sunstrike. Any queries should be directed to him, not AlgorithmX2.
|
||||
*/
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import cpw.mods.fml.common.DummyModContainer;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.LoadController;
|
||||
import cpw.mods.fml.common.ModMetadata;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class TConstructLoaderContainer extends DummyModContainer implements IFMLLoadingPlugin {
|
||||
|
||||
private final String[] asmTransformers = new String[]{"tconstruct.preloader.ASMInterfaceRepair"};
|
||||
private final ModMetadata md = new ModMetadata();
|
||||
|
||||
protected static Logger logger = Logger.getLogger("TCon-Preloader");
|
||||
|
||||
public TConstructLoaderContainer() {
|
||||
logger.setParent(FMLLog.getLogger());
|
||||
logger.info("Scalpel. Suction. Lumber axe. CLEAR! *zap*");
|
||||
logger.info("Constructing preloader (Modules: " + Arrays.toString(asmTransformers) + ")");
|
||||
md.autogenerated = true;
|
||||
md.credits = "AlgorithmX2 (original) and Sunstrike (porting)";
|
||||
md.modId = getModId();
|
||||
md.version = getVersion();
|
||||
md.name = getName();
|
||||
md.authorList = Arrays.asList("AlgorithmX2", "Sunstrike");
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void preInit(FMLPreInitializationEvent evt) {
|
||||
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void init(FMLInitializationEvent evt) {
|
||||
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void postInit(FMLPostInitializationEvent evt) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModId() {
|
||||
return "TConstruct-Preloader";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Tinkers Corestruct";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "0.0.1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayVersion() {
|
||||
return getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModMetadata getMetadata() {
|
||||
return md;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerBus(EventBus bus, LoadController controller) {
|
||||
bus.register(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getLibraryRequestClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getASMTransformerClass() {
|
||||
return asmTransformers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModContainerClass() {
|
||||
return "tconstruct.preloader.TConstructLoaderContainer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSetupClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectData(Map<String, Object> data) {}
|
||||
}
|
||||
Reference in new issue
Block a user