package launcher;

import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

import net.minecraft.client.Minecraft;

/**
 * Utility class to start Minecraft in a development environment.
 * Suggested VM arguments:
 * -Djava.library.path=lib/natives -Xmx1G -Xms1G
 */
public class StartMinecraftDev {
    public static void main(String[] args) {
        try {
            // Change the minecraft data folder to a portable location.
            Field dataFolder = Minecraft.class.getDeclaredField("am");
            dataFolder.setAccessible(true);
            dataFolder.set(null, new File("mcdev"));

            // Force ModLoader to recognize mods outside of minecraft.jar.
            // Make sure you've built the LibShapeDraw jar with Maven already.
            Method readFromClassPath = Class.forName("ModLoader").getDeclaredMethod("readFromClassPath", File.class);
            readFromClassPath.setAccessible(true);
            for (File jar : new File("target").listFiles()) {
                if (jar.isFile() && jar.getName().endsWith(".jar")) {
                    readFromClassPath.invoke(null, jar);
                }
            }

            Minecraft.main(args);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

@@ -209,16 +209,139 @@
 onment.%0A
+ * %3Cp%3E%0A * You'll need to run this once to setup ModLoader before it can load any mods%0A * (including LibDrawShapes).%0A * %3Cp%3E%0A
  * Sugge
@@ -504,16 +504,61 @@
   try %7B%0A
+            File mcdev = new File(%22mcdev%22);%0A%0A
         
@@ -692,16 +692,206 @@
 (%22am%22);%0A
+            if (dataFolder.getType() != File.class) %7B%0A                throw new RuntimeException(%22expected File field not found on Minecraft; obfuscation may be out of date%22);%0A            %7D%0A
         
@@ -963,29 +963,55 @@
 ll, 
-new File(%22mcdev%22));%0A%0A
+mcdev);%0A%0A            if (mcdev.exists()) %7B%0A    
     
@@ -1093,16 +1093,20 @@
         
+   
+ 
 // Make 
@@ -1164,16 +1164,20 @@
 lready.%0A
+    
         
@@ -1290,32 +1290,36 @@
 s);%0A            
+   
+ 
 readFromClassPat
@@ -1333,32 +1333,36 @@
 cessible(true);%0A
+    
             for 
@@ -1403,24 +1403,28 @@
 tFiles()) %7B%0A
+    
             
@@ -1493,32 +1493,36 @@
                 
+    
 readFromClassPat
@@ -1542,16 +1542,38 @@
 , jar);%0A
+                    %7D%0A
         
@@ -1595,16 +1595,296 @@
        %7D
+%0A            // Else ModLoader will crash and burn. Not worth the time digging%0A            // into its internals to figure out why -- the first time you run%0A            // this launcher, just start and stop it once to get everything%0A            // initialized, and then it's fine.
 %0A%0A      

fix a couple minor issues with test launcher