Updated FML, Should fix a lot of installing issues for MCP.

Made patches error and not apply if the target file is not found.
Updated Event Transformer to add a default constructor...
Fixed 4096 setup code in MinecraftForge.initalize()
This commit is contained in:
LexManos 2012-08-12 05:14:32 -07:00
parent da426653a8
commit a024be74e6
4 changed files with 40 additions and 17 deletions

View file

@ -1,11 +1,14 @@
package net.minecraftforge.common;
import java.lang.reflect.Constructor;
import java.util.*;
import net.minecraft.src.*;
import net.minecraftforge.common.ForgeHooks.GrassEntry;
import net.minecraftforge.common.ForgeHooks.SeedEntry;
import net.minecraftforge.event.EventBus;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.EntityEvent;
public class MinecraftForge
{
@ -170,12 +173,15 @@ public class MinecraftForge
Block filler = null;
try
{
filler = Block.class.getConstructor(int.class, Material.class).newInstance(256, Material.air);
}catch (Exception e){}
if (filler == null)
Constructor ctr = Block.class.getDeclaredConstructor(int.class, Material.class);
ctr.setAccessible(true);
filler = (Block)ctr.newInstance(256, Material.air);
}
catch (Exception e)
{
throw new RuntimeException("Could not create Forge filler block");
RuntimeException rte = new RuntimeException("Could not create Forge filler block", e);
rte.printStackTrace();
System.exit(1);
}
for (int x = 256; x < 4096; x++)

View file

@ -59,6 +59,7 @@ public class EventTransformer implements IClassTransformer
boolean hasSetup = false;
boolean hasGetListenerList = false;
boolean hasDefaultCtr = false;
Type tList = Type.getType(ListenerList.class);
@ -76,6 +77,11 @@ public class EventTransformer implements IClassTransformer
{
hasGetListenerList = true;
}
if (method.name.equals("<init>") &&
method.desc.equals(Type.getMethodDescriptor(VOID_TYPE)))
{
hasDefaultCtr = true;
}
}
if (hasSetup)
@ -95,6 +101,21 @@ public class EventTransformer implements IClassTransformer
//Add private static ListenerList LISTENER_LIST
classNode.fields.add(new FieldNode(ACC_PRIVATE | ACC_STATIC, "LISTENER_LIST", tList.getDescriptor(), null, null));
/*Add:
* public <init>()
* {
* super();
* }
*/
MethodNode method = new MethodNode(ASM4, ACC_PUBLIC, "<init>", getMethodDescriptor(VOID_TYPE), null, null);
method.instructions.add(new VarInsnNode(ALOAD, 0));
method.instructions.add(new MethodInsnNode(INVOKESPECIAL, tSuper.getInternalName(), "<init>", getMethodDescriptor(VOID_TYPE)));
method.instructions.add(new InsnNode(RETURN));
if (!hasDefaultCtr)
{
classNode.methods.add(method);
}
/*Add:
* protected void setup()
* {
@ -106,7 +127,7 @@ public class EventTransformer implements IClassTransformer
* LISTENER_LIST = new ListenerList(super.getListenerList());
* }
*/
MethodNode method = new MethodNode(ASM4, ACC_PROTECTED, "setup", getMethodDescriptor(VOID_TYPE), null, null);
method = new MethodNode(ASM4, ACC_PROTECTED, "setup", getMethodDescriptor(VOID_TYPE), null, null);
method.instructions.add(new VarInsnNode(ALOAD, 0));
method.instructions.add(new MethodInsnNode(INVOKESPECIAL, tSuper.getInternalName(), "setup", getMethodDescriptor(VOID_TYPE)));
method.instructions.add(new FieldInsnNode(GETSTATIC, classNode.name, "LISTENER_LIST", tList.getDescriptor()));

View file

@ -89,16 +89,12 @@ def apply_forge_patches(fml_dir, mcp_dir, forge_dir, src_dir, copy_files=True):
if has_client:
if os.path.isdir(os.path.join(forge_dir, 'patches', 'minecraft')):
apply_patches(mcp_dir, os.path.join(forge_dir, 'patches', 'minecraft'), src_dir)
if os.path.isdir(os.path.join(forge_dir, 'patches', 'common')):
apply_patches(mcp_dir, os.path.join(forge_dir, 'patches', 'common'), src_dir, '/common/', '/minecraft/')
if copy_files and os.path.isdir(os.path.join(forge_dir, 'client')):
copytree(os.path.join(forge_dir, 'client'), os.path.join(src_dir, 'minecraft'))
if has_server:
if os.path.isdir(os.path.join(forge_dir, 'patches', 'minecraft_server')):
apply_patches(mcp_dir, os.path.join(forge_dir, 'patches', 'minecraft_server'), src_dir)
if os.path.isdir(os.path.join(forge_dir, 'patches', 'common')):
apply_patches(mcp_dir, os.path.join(forge_dir, 'patches', 'common'), src_dir, '/common/', '/minecraft_server/')
if copy_files and os.path.isdir(os.path.join(forge_dir, 'server')):
copytree(os.path.join(forge_dir, 'server'), os.path.join(src_dir, 'minecraft_server'))