Primitive capability for tweakers to order. Add a "TweakOrder" integer
property to your manifest, or accept the default of zero.
This commit is contained in:
parent
efead4d200
commit
5e03f2e85b
2 changed files with 25 additions and 6 deletions
|
@ -22,6 +22,7 @@ import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.ObjectArrays;
|
import com.google.common.collect.ObjectArrays;
|
||||||
|
import com.google.common.primitives.Ints;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||||
|
|
||||||
|
@ -37,6 +38,7 @@ public class FMLTweaker implements ITweaker {
|
||||||
private Map<String, String> launchArgs;
|
private Map<String, String> launchArgs;
|
||||||
private List<String> standaloneArgs;
|
private List<String> standaloneArgs;
|
||||||
private static URI jarLocation;
|
private static URI jarLocation;
|
||||||
|
private List<Integer> sortOrderValues = Lists.newArrayList();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile)
|
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile)
|
||||||
|
@ -156,10 +158,24 @@ public class FMLTweaker implements ITweaker {
|
||||||
return jarLocation;
|
return jarLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void injectCascadingTweak(String tweakClassName)
|
public void injectCascadingTweak(String tweakClassName, Integer sortingOrder)
|
||||||
{
|
{
|
||||||
List<String> tweakClasses = (List<String>) Launch.blackboard.get("TweakClasses");
|
List<String> tweakClasses = (List<String>) Launch.blackboard.get("TweakClasses");
|
||||||
tweakClasses.add(tweakClassName);
|
if (tweakClasses.size() != sortOrderValues.size())
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Sort ordering mismatch!");
|
||||||
|
}
|
||||||
|
int i = 0;
|
||||||
|
for (i = 0; i < sortOrderValues.size(); i++)
|
||||||
|
{
|
||||||
|
Integer sort = sortOrderValues.get(i);
|
||||||
|
if (sort.compareTo(sortingOrder) > 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tweakClasses.add(i, tweakClassName);
|
||||||
|
sortOrderValues.add(i, sortingOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ import com.google.common.base.Throwables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.ObjectArrays;
|
import com.google.common.collect.ObjectArrays;
|
||||||
|
import com.google.common.primitives.Ints;
|
||||||
|
|
||||||
import cpw.mods.fml.common.FMLLog;
|
import cpw.mods.fml.common.FMLLog;
|
||||||
import cpw.mods.fml.common.launcher.FMLTweaker;
|
import cpw.mods.fml.common.launcher.FMLTweaker;
|
||||||
|
@ -200,7 +201,9 @@ public class CoreModManager
|
||||||
if (cascadedTweaker != null)
|
if (cascadedTweaker != null)
|
||||||
{
|
{
|
||||||
FMLRelaunchLog.info("Loading tweaker %s from %s", cascadedTweaker, coreMod.getName());
|
FMLRelaunchLog.info("Loading tweaker %s from %s", cascadedTweaker, coreMod.getName());
|
||||||
handleCascadingTweak(coreMod, jar, cascadedTweaker, classLoader);
|
Integer sortOrder = Ints.tryParse(mfAttributes.getValue("TweakOrder"));
|
||||||
|
sortOrder = (sortOrder == null ? Integer.valueOf(0) : sortOrder);
|
||||||
|
handleCascadingTweak(coreMod, jar, cascadedTweaker, classLoader, sortOrder);
|
||||||
loadedCoremods.add(coreMod.getName());
|
loadedCoremods.add(coreMod.getName());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -237,7 +240,7 @@ public class CoreModManager
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Method ADDURL;
|
private static Method ADDURL;
|
||||||
private static void handleCascadingTweak(File coreMod, JarFile jar, String cascadedTweaker, LaunchClassLoader classLoader)
|
private static void handleCascadingTweak(File coreMod, JarFile jar, String cascadedTweaker, LaunchClassLoader classLoader, Integer sortingOrder)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -249,7 +252,7 @@ public class CoreModManager
|
||||||
}
|
}
|
||||||
ADDURL.invoke(classLoader.getClass().getClassLoader(), coreMod.toURI().toURL());
|
ADDURL.invoke(classLoader.getClass().getClassLoader(), coreMod.toURI().toURL());
|
||||||
classLoader.addURL(coreMod.toURI().toURL());
|
classLoader.addURL(coreMod.toURI().toURL());
|
||||||
CoreModManager.tweaker.injectCascadingTweak(cascadedTweaker);
|
CoreModManager.tweaker.injectCascadingTweak(cascadedTweaker, sortingOrder);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -452,6 +455,6 @@ public class CoreModManager
|
||||||
}
|
}
|
||||||
|
|
||||||
Launch.blackboard.put("fml.deobfuscatedEnvironment", deobfuscatedEnvironment);
|
Launch.blackboard.put("fml.deobfuscatedEnvironment", deobfuscatedEnvironment);
|
||||||
tweaker.injectCascadingTweak("cpw.mods.fml.common.launcher.FMLDeobfTweaker");
|
tweaker.injectCascadingTweak("cpw.mods.fml.common.launcher.FMLDeobfTweaker", Integer.valueOf(1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue