Minecraft custom launcher - forge mod load

2019-08-15 06:03发布

问题:

I'm trying to make a launcher for minecraft.

When I launch it from workspace (in C:/users/hugo/workspace), everything work perfectly.

But when I run the launcher from desktop, it try to load mods from ALL folders in the desktop. It create a "logs" folder in the desktop folder too.

my launch command (without library load and after generation):

javaw -Xmx1024M -Xms1024M -XX:MaxPermSize=256M 
-Djava.library.path=C:\Users\Hugo\AppData\Roaming\Survival-Machines\game1\natives
-cp "C:\Users\Hugo\AppData...versions\1.7.10\1.7.10.jar;"
net.minecraft.launchwrapper.Launch
--tweakClass cpw.mods.fml.common.launcher.FMLTweaker
--username Slaynash
--version 1.7.10
--gameDir C:\Users\Hugo\AppData\Roaming\Survival-Machines\game1\
--assetsDir C:\Users\Hugo\AppData\Roaming\Survival-Machines\game1\assets
--assetIndex 1.7.10
--uuid 32********a3
--userProperties {}
--accessToken fa********cc

I launch it with java and function Runtime.getRuntime().exec(String cmd);

Is my launch command bad, or have i forgot an argument ?

Thanks for help, Hugo

and sorry for my bad english :/

回答1:

I think it's in the launch command - I suggest you use a different override of the exec() method - one that allows you to set the working folder.

Your current one just inherits the current working directory, evidently the desktop.

Instead, use Runtime.getRuntime().exec(String cmd, String[] argp, File dir);

This lets you tell java where to start the application, which will presumably be the folder that contains your mods.

https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#exec(java.lang.String,%20java.lang.String[],%20java.io.File)