net.minecraft.launchwrapper.ITweaker Java Examples
The following examples show how to use
net.minecraft.launchwrapper.ITweaker.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MixinPlatformAgentFMLLegacy.java From Mixin with MIT License | 6 votes |
@Override public String getSideName() { // Using this method first prevents us from accidentally loading FML // classes too early when using the tweaker in dev List<ITweaker> tweakerList = GlobalProperties.<List<ITweaker>>get(MixinServiceLaunchWrapper.BLACKBOARD_KEY_TWEAKS); if (tweakerList == null) { return null; } for (ITweaker tweaker : tweakerList) { if (tweaker.getClass().getName().endsWith(MixinPlatformAgentFMLLegacy.SERVER_TWEAKER_TAIL)) { return Constants.SIDE_SERVER; } else if (tweaker.getClass().getName().endsWith(MixinPlatformAgentFMLLegacy.CLIENT_TWEAKER_TAIL)) { return Constants.SIDE_CLIENT; } } String name = MixinPlatformAgentAbstract.invokeStringMethod(Launch.classLoader, MixinPlatformAgentFMLLegacy.NEW_LAUNCH_HANDLER_CLASS, MixinPlatformAgentFMLLegacy.GETSIDE_METHOD); if (name != null) { return name; } return MixinPlatformAgentAbstract.invokeStringMethod(Launch.classLoader, MixinPlatformAgentFMLLegacy.OLD_LAUNCH_HANDLER_CLASS, MixinPlatformAgentFMLLegacy.GETSIDE_METHOD); }
Example #2
Source File: LegacyJavaFixer.java From LegacyJavaFixer with MIT License | 6 votes |
public LegacyJavaFixer() { @SuppressWarnings("unchecked") ListIterator<ITweaker> itr = ((List<ITweaker>)Launch.blackboard.get("Tweaks")).listIterator(); ITweaker replacement = new SortReplacement(); while (itr.hasNext()) { ITweaker t = itr.next(); FMLRelaunchLog.log.info("[LegacyJavaFixer] Tweaker: " + t); if (t instanceof FMLInjectionAndSortingTweaker) { itr.set(replacement); FMLRelaunchLog.info("[LegacyJavaFixer] Replacing tweaker %s with %s", t, replacement); } } }
Example #3
Source File: MixinPlatformAgentFMLLegacy.java From Mixin with MIT License | 5 votes |
/** * Attempts to initialise the FML coremod (if specified in the jar metadata) */ private ITweaker initFMLCoreMod() { try { if ("true".equalsIgnoreCase(this.handle.getAttribute(MixinPlatformAgentFMLLegacy.MFATT_FORCELOADASMOD))) { MixinPlatformAgentAbstract.logger.debug("ForceLoadAsMod was specified for {}, attempting force-load", this.fileName); this.loadAsMod(); } return this.injectCorePlugin(); } catch (Exception ex) { MixinPlatformAgentAbstract.logger.catching(ex); return null; } }
Example #4
Source File: MixinPlatformAgentFMLLegacy.java From Mixin with MIT License | 5 votes |
private ITweaker injectCorePlugin() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { String coreModName = this.handle.getAttribute(MixinPlatformAgentFMLLegacy.MFATT_FMLCOREPLUGIN); if (coreModName == null) { return null; } if (this.isAlreadyInjected(coreModName)) { MixinPlatformAgentAbstract.logger.debug("{} has core plugin {}. Skipping because it was already injected.", this.fileName, coreModName); return null; } MixinPlatformAgentAbstract.logger.debug("{} has core plugin {}. Injecting it into FML for co-initialisation:", this.fileName, coreModName); Method mdLoadCoreMod = this.clCoreModManager.getDeclaredMethod(GlobalProperties.getString(GlobalProperties.Keys.FML_LOAD_CORE_MOD, MixinPlatformAgentFMLLegacy.LOAD_CORE_MOD_METHOD), LaunchClassLoader.class, String.class, File.class); mdLoadCoreMod.setAccessible(true); ITweaker wrapper = (ITweaker)mdLoadCoreMod.invoke(null, Launch.classLoader, coreModName, this.file); if (wrapper == null) { MixinPlatformAgentAbstract.logger.debug("Core plugin {} could not be loaded.", coreModName); return null; } // If the injection tweaker is queued, we are most likely in development // and will NOT need to co-init the coremod this.initInjectionState = MixinPlatformAgentFMLLegacy.isTweakerQueued(MixinPlatformAgentFMLLegacy.FML_TWEAKER_INJECTION); MixinPlatformAgentFMLLegacy.loadedCoreMods.add(coreModName); return wrapper; }
Example #5
Source File: MixinPlatformAgentFMLLegacy.java From Mixin with MIT License | 5 votes |
private boolean isAlreadyInjected(String coreModName) { // Did we already inject this ourselves, or was it specified on the command line if (MixinPlatformAgentFMLLegacy.loadedCoreMods.contains(coreModName)) { return true; } // Was it already loaded, check the tweakers list try { List<ITweaker> tweakers = GlobalProperties.<List<ITweaker>>get(MixinServiceLaunchWrapper.BLACKBOARD_KEY_TWEAKS); if (tweakers == null) { return false; } for (ITweaker tweaker : tweakers) { Class<? extends ITweaker> tweakClass = tweaker.getClass(); if (MixinPlatformAgentFMLLegacy.FML_PLUGIN_WRAPPER_CLASS.equals(tweakClass.getSimpleName())) { Field fdCoreModInstance = tweakClass.getField(MixinPlatformAgentFMLLegacy.FML_CORE_MOD_INSTANCE_FIELD); fdCoreModInstance.setAccessible(true); Object coreMod = fdCoreModInstance.get(tweaker); if (coreModName.equals(coreMod.getClass().getName())) { return true; } } } } catch (Exception ex) { // ex.printStackTrace(); } return false; }
Example #6
Source File: LegacyJavaFixer.java From LegacyJavaFixer with MIT License | 5 votes |
@SuppressWarnings("unchecked") private void sort() { List<ITweaker> tweakers = (List<ITweaker>) Launch.blackboard.get("Tweaks"); // Basically a copy of Collections.sort pre 8u20, optimized as we know we're an array list. // Thanks unhelpful fixer of http://bugs.java.com/view_bug.do?bug_id=8032636 ITweaker[] toSort = tweakers.toArray(new ITweaker[tweakers.size()]); Arrays.sort(toSort, new Comparator<ITweaker>() { @Override public int compare(ITweaker o1, ITweaker o2) { return Ints.saturatedCast((long)getIndex(o1) - (long)getIndex(o2)); } private int getIndex(ITweaker t) { try { if (t instanceof SortReplacement) return Integer.MIN_VALUE; if (wrapperCls.isInstance(t)) return wrapperField.getInt(t); if (tweakSorting.containsKey(t.getClass().getName())) return tweakSorting.get(t.getClass().getName()); } catch (Exception e) { Throwables.propagate(e); } return 0; } }); // Basically a copy of Collections.sort, optimized as we know we're an array list. // Thanks unhelpful fixer of http://bugs.java.com/view_bug.do?bug_id=8032636 for (int j = 0; j < toSort.length; j++) { tweakers.set(j, toSort[j]); } }