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,14 +173,17 @@ 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)
{
throw new RuntimeException("Could not create Forge filler block");
Constructor ctr = Block.class.getDeclaredConstructor(int.class, Material.class);
ctr.setAccessible(true);
filler = (Block)ctr.newInstance(256, Material.air);
}
catch (Exception e)
{
RuntimeException rte = new RuntimeException("Could not create Forge filler block", e);
rte.printStackTrace();
System.exit(1);
}
for (int x = 256; x < 4096; x++)
{
if (Item.itemsList[x - 256] != null)

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);
@ -68,13 +69,18 @@ public class EventTransformer implements IClassTransformer
method.desc.equals(Type.getMethodDescriptor(VOID_TYPE)) &&
(method.access & ACC_PROTECTED) == ACC_PROTECTED)
{
hasSetup = true;
hasSetup = true;
}
if (method.name.equals("getListenerList") &&
method.desc.equals(Type.getMethodDescriptor(tList)) &&
(method.access & ACC_PUBLIC) == ACC_PUBLIC)
method.desc.equals(Type.getMethodDescriptor(tList)) &&
(method.access & ACC_PUBLIC) == ACC_PUBLIC)
{
hasGetListenerList = true;
hasGetListenerList = true;
}
if (method.name.equals("<init>") &&
method.desc.equals(Type.getMethodDescriptor(VOID_TYPE)))
{
hasDefaultCtr = true;
}
}
@ -94,7 +100,22 @@ 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'))