Java Examples for net.minecraft.launchwrapper.ITweaker
The following java examples will help you to understand the usage of net.minecraft.launchwrapper.ITweaker. These source code samples are taken from different open source projects.
Example 1
| Project: WildAnimalsPlus-1.7.10-master File: CoreModManager.java View source code |
public static void injectCoreModTweaks(FMLInjectionAndSortingTweaker fmlInjectionAndSortingTweaker) {
@SuppressWarnings("unchecked") List<ITweaker> tweakers = (List<ITweaker>) Launch.blackboard.get("Tweaks");
// Add the sorting tweaker first- it'll appear twice in the list
tweakers.add(0, fmlInjectionAndSortingTweaker);
for (FMLPluginWrapper wrapper : loadPlugins) {
tweakers.add(wrapper);
}
}Example 2
| Project: Mixin-master File: MixinEnvironment.java View source code |
protected final String getSideName() {
// too early when using the tweaker in dev
for (ITweaker tweaker : Blackboard.<List<ITweaker>>get(Blackboard.Keys.TWEAKS)) {
if (tweaker.getClass().getName().endsWith(".common.launcher.FMLServerTweaker")) {
return "SERVER";
} else if (tweaker.getClass().getName().endsWith(".common.launcher.FMLTweaker")) {
return "CLIENT";
}
}
String name = this.getSideName("net.minecraftforge.fml.relauncher.FMLLaunchHandler", "side");
if (name != null) {
return name;
}
name = this.getSideName("cpw.mods.fml.relauncher.FMLLaunchHandler", "side");
if (name != null) {
return name;
}
name = this.getSideName("com.mumfrey.liteloader.launch.LiteLoaderTweaker", "getEnvironmentType");
if (name != null) {
return name;
}
return "UNKNOWN";
}Example 3
| Project: opendata-master File: ModMetaCollector.java View source code |
private void collectFilesFromTweakers(Collection<ITweaker> tweakers, ASMDataTable table) { try { Class<?> coreModWrapper = Class.forName("net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper"); Field nameField = coreModWrapper.getField("name"); nameField.setAccessible(true); Field pluginField = coreModWrapper.getField("coreModInstance"); pluginField.setAccessible(true); Field locationField = coreModWrapper.getField("location"); locationField.setAccessible(true); for (ITweaker tweaker : tweakers) { try { File location = (File) locationField.get(tweaker); if (location == null || location.isDirectory()) continue; String name = (String) nameField.get(tweaker); IFMLLoadingPlugin plugin = (IFMLLoadingPlugin) pluginField.get(tweaker); FileMeta meta = getOrCreateData(location); meta.tweakers.add(new TweakMeta(name, plugin.getClass().getName())); } catch (Throwable t) { Log.warn(t, "Can't get data for tweaker %s", tweaker); } } } catch (Throwable t) { Log.warn(t, "Can't get tweaker data"); } }
Example 4
| Project: MinecraftForkage-master File: CoreModManager.java View source code |
@Override public int compare(ITweaker o1, ITweaker o2) { Integer first = null; Integer second = null; if (o1 instanceof FMLInjectionAndSortingTweaker) { first = Integer.MIN_VALUE; } if (o2 instanceof FMLInjectionAndSortingTweaker) { second = Integer.MIN_VALUE; } if (o1 instanceof FMLPluginWrapper) { first = ((FMLPluginWrapper) o1).sortIndex; } else if (first == null) { first = tweakSorting.get(o1.getClass().getName()); } if (o2 instanceof FMLPluginWrapper) { second = ((FMLPluginWrapper) o2).sortIndex; } else if (second == null) { second = tweakSorting.get(o2.getClass().getName()); } if (first == null) { first = 0; } if (second == null) { second = 0; } return Ints.saturatedCast((long) first - (long) second); }
Example 5
| Project: ForgeGradle-master File: CoremodTweaker.java View source code |
@Override
@SuppressWarnings("unchecked")
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
try {
Field coreModList = Class.forName("net.minecraftforge.fml.relauncher.CoreModManager", true, classLoader).getDeclaredField("loadPlugins");
coreModList.setAccessible(true);
// grab constructor.
Class<ITweaker> clazz = (Class<ITweaker>) Class.forName("net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper", true, classLoader);
Constructor<ITweaker> construct = (Constructor<ITweaker>) clazz.getConstructors()[0];
construct.setAccessible(true);
Field[] fields = clazz.getDeclaredFields();
// 1
Field pluginField = fields[1];
// 3
Field fileField = fields[3];
// 2
Field listField = fields[2];
Field.setAccessible(clazz.getConstructors(), true);
Field.setAccessible(fields, true);
List<ITweaker> oldList = (List<ITweaker>) coreModList.get(null);
for (int i = 0; i < oldList.size(); i++) {
ITweaker tweaker = oldList.get(i);
if (clazz.isInstance(tweaker)) {
Object coreMod = pluginField.get(tweaker);
Object oldFile = fileField.get(tweaker);
File newFile = GradleForgeHacks.coreMap.get(coreMod.getClass().getCanonicalName());
LOGGER.info("Injecting location in coremod {}", coreMod.getClass().getCanonicalName());
if (newFile != null && oldFile == null) {
// build new tweaker.
oldList.set(i, construct.newInstance(new Object[] { // name
(String) fields[0].get(tweaker), // coremod
coreMod, // location
newFile, // sort index?
fields[4].getInt(tweaker), ((List<String>) listField.get(tweaker)).toArray(new String[0]) }));
}
}
}
} catch (Throwable t) {
LOGGER.log(Level.ERROR, "Something went wrong with the coremod adding.");
t.printStackTrace();
}
// inject the additional AT tweaker
String atTweaker = "net.minecraftforge.gradle.tweakers.AccessTransformerTweaker";
((List<String>) Launch.blackboard.get("TweakClasses")).add(atTweaker);
// make sure its after the deobf tweaker
try {
Field f = Class.forName(COREMOD_CLASS, true, classLoader).getDeclaredField(TWEAKER_SORT_FIELD);
f.setAccessible(true);
((Map<String, Integer>) f.get(null)).put(atTweaker, Integer.valueOf(1001));
} catch (Throwable t) {
LOGGER.log(Level.ERROR, "Something went wrong with the adding the AT tweaker adding.");
t.printStackTrace();
}
}Example 6
| Project: FML-master File: CoreModManager.java View source code |
public static void injectCoreModTweaks(FMLInjectionAndSortingTweaker fmlInjectionAndSortingTweaker) {
@SuppressWarnings("unchecked") List<ITweaker> tweakers = (List<ITweaker>) Launch.blackboard.get("Tweaks");
// Add the sorting tweaker first- it'll appear twice in the list
tweakers.add(0, fmlInjectionAndSortingTweaker);
for (FMLPluginWrapper wrapper : loadPlugins) {
tweakers.add(wrapper);
}
}Example 7
| Project: MinecraftForge-master File: CoreModManager.java View source code |
public static void injectCoreModTweaks(FMLInjectionAndSortingTweaker fmlInjectionAndSortingTweaker) {
@SuppressWarnings("unchecked") List<ITweaker> tweakers = (List<ITweaker>) Launch.blackboard.get("Tweaks");
// Add the sorting tweaker first- it'll appear twice in the list
tweakers.add(0, fmlInjectionAndSortingTweaker);
for (FMLPluginWrapper wrapper : loadPlugins) {
tweakers.add(wrapper);
}
}