net.minecraft.launchwrapper.Launch Java Examples
The following examples show how to use
net.minecraft.launchwrapper.Launch.
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: MixinServiceLaunchWrapperBootstrap.java From Mixin with MIT License | 6 votes |
@Override public void bootstrap() { try { Launch.classLoader.hashCode(); } catch (Throwable th) { throw new ServiceInitialisationException(this.getName() + " is not available"); } // Essential ones Launch.classLoader.addClassLoaderExclusion(MixinServiceLaunchWrapperBootstrap.SERVICE_PACKAGE); // Important ones Launch.classLoader.addClassLoaderExclusion(MixinServiceLaunchWrapperBootstrap.ASM_PACKAGE); Launch.classLoader.addClassLoaderExclusion(MixinServiceLaunchWrapperBootstrap.LEGACY_ASM_PACKAGE); Launch.classLoader.addClassLoaderExclusion(MixinServiceLaunchWrapperBootstrap.MIXIN_PACKAGE); Launch.classLoader.addClassLoaderExclusion(MixinServiceLaunchWrapperBootstrap.MIXIN_UTIL_PACKAGE); }
Example #2
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 #3
Source File: ClassDiscoverer.java From CodeChickenCore with MIT License | 6 votes |
private void checkAddClass(String resource) { try { String classname = resource.replace(".class", "").replace("\\", ".").replace("/", "."); byte[] bytes = Launch.classLoader.getClassBytes(classname); if (bytes == null) return; ClassNode cnode = ASMHelper.createClassNode(bytes); for (String superclass : superclasses) if (!cnode.interfaces.contains(superclass) && !cnode.superName.equals(superclass)) return; addClass(classname); } catch (IOException e) { CodeChickenCorePlugin.logger.error("Unable to load class: " + resource, e); } }
Example #4
Source File: Meddle.java From Meddle with GNU Lesser General Public License v3.0 | 6 votes |
@SuppressWarnings("unchecked") public Meddle() { // Prevent classloader collisions, mostly due to keeping // the deprecated DynamicMappings class. Launch.classLoader.addClassLoaderExclusion("org.objectweb.asm."); blacklistedTweaks.add(Meddle.class.getName()); // Launchwrapper adds the package without a period on the end, which // covers any similarly-named packages. We could solve by putting // Meddle's tweak class in a deeper package, but this works too // while maintaining backwards compatibility. try { Field exceptionsField = LaunchClassLoader.class.getDeclaredField("classLoaderExceptions"); exceptionsField.setAccessible(true); classloaderExceptions = (Set<String>) exceptionsField.get(Launch.classLoader); } catch (Exception e) { e.printStackTrace(); } classloaderExceptions.remove("net.fybertech.meddle"); classloaderExceptions.add("net.fybertech.meddle."); }
Example #5
Source File: SafeClassWriter.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected String getCommonSuperClass(String type1, String type2) { Class<?> c, d; ClassLoader classLoader = Launch.classLoader; try { c = Class.forName(type1.replace('/', '.'), false, classLoader); d = Class.forName(type2.replace('/', '.'), false, classLoader); } catch (Exception e) { throw new RuntimeException(e.toString()); } if (c.isAssignableFrom(d)) { return type1; } if (d.isAssignableFrom(c)) { return type2; } if (c.isInterface() || d.isInterface()) { return "java/lang/Object"; } else { do { c = c.getSuperclass(); } while (!c.isAssignableFrom(d)); return c.getName().replace('.', '/'); } }
Example #6
Source File: LegacyJavaFixer.java From LegacyJavaFixer with MIT License | 6 votes |
@Override public void injectIntoClassLoader(LaunchClassLoader classLoader) { if (!hasRun) { FMLRelaunchLog.log.info("[LegacyJavaFixer] Replacing sort"); sort(); URL is = FMLInjectionAndSortingTweaker.class.getResource("/cpw/mods/fml/common/launcher/TerminalTweaker.class"); if (is != null) { FMLRelaunchLog.log.info("[LegacyJavaFixer] Detected TerminalTweaker"); @SuppressWarnings("unchecked") List<String> newTweaks = (List<String>) Launch.blackboard.get("TweakClasses"); newTweaks.add("cpw.mods.fml.common.launcher.TerminalTweaker"); } } hasRun = true; }
Example #7
Source File: VanillaFixLoadingPlugin.java From VanillaFix with MIT License | 6 votes |
private static void initStacktraceDeobfuscator() { File modDir = new File(Launch.minecraftHome, "config/vanillafix"); modDir.mkdirs(); // Initialize StacktraceDeobfuscator log.info("Initializing StacktraceDeobfuscator"); try { File mappings = new File(modDir, "methods-stable_39.csv"); if (mappings.exists()) { log.info("Found MCP method mappings: " + mappings.getName()); } else { log.info("Downloading MCP method mappings to: " + mappings.getName()); } StacktraceDeobfuscator.init(mappings); } catch (Exception e) { log.error("Failed to get MCP data!", e); } log.info("Done initializing StacktraceDeobfuscator"); // Install the log exception deobfuscation rewrite policy DeobfuscatingRewritePolicy.install(); }
Example #8
Source File: MemoryHelper.java From Hyperium with GNU Lesser General Public License v3.0 | 6 votes |
@InvokeEvent public void tickEvent(TickEvent event) { if (tickCounter % 20 * 60 == 0) { Minecraft.memoryReserve = new byte[0]; try { Field resourceCache = LaunchClassLoader.class.getDeclaredField("resourceCache"); resourceCache.setAccessible(true); ((Map) resourceCache.get(Launch.classLoader)).clear(); Field packageManifests = LaunchClassLoader.class.getDeclaredField("packageManifests"); packageManifests.setAccessible(true); ((Map) packageManifests.get(Launch.classLoader)).clear(); } catch (IllegalAccessException | NoSuchFieldException e) { e.printStackTrace(); } } tickCounter++; }
Example #9
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 #10
Source File: ClassTweaker.java From The-5zig-Mod with MIT License | 6 votes |
@Override public String[] getLaunchArguments() { ArrayList<String> argumentList = (ArrayList<String>) Launch.blackboard.get("ArgumentList"); if (argumentList.isEmpty()) { if (gameDir != null) { argumentList.add("--gameDir"); argumentList.add(gameDir.getPath()); } if (assetsDir != null) { argumentList.add("--assetsDir"); argumentList.add(assetsDir.getPath()); } argumentList.add("--version"); argumentList.add(version); argumentList.addAll(args); } return new String[0]; }
Example #11
Source File: ClassTweaker.java From The-5zig-Mod with MIT License | 6 votes |
@Override public String[] getLaunchArguments() { ArrayList<String> argumentList = (ArrayList<String>) Launch.blackboard.get("ArgumentList"); if (argumentList.isEmpty()) { if (gameDir != null) { argumentList.add("--gameDir"); argumentList.add(gameDir.getPath()); } if (assetsDir != null) { argumentList.add("--assetsDir"); argumentList.add(assetsDir.getPath()); } argumentList.add("--version"); argumentList.add(version); argumentList.addAll(args); } return new String[0]; }
Example #12
Source File: ClassTweaker.java From The-5zig-Mod with MIT License | 6 votes |
@Override public String[] getLaunchArguments() { ArrayList<String> argumentList = (ArrayList<String>) Launch.blackboard.get("ArgumentList"); if (argumentList.isEmpty()) { if (gameDir != null) { argumentList.add("--gameDir"); argumentList.add(gameDir.getPath()); } if (assetsDir != null) { argumentList.add("--assetsDir"); argumentList.add(assetsDir.getPath()); } argumentList.add("--version"); argumentList.add(version); argumentList.addAll(args); } return new String[0]; }
Example #13
Source File: ClassTweaker.java From The-5zig-Mod with MIT License | 6 votes |
@Override public String[] getLaunchArguments() { ArrayList<String> argumentList = (ArrayList<String>) Launch.blackboard.get("ArgumentList"); if (argumentList.isEmpty()) { if (gameDir != null) { argumentList.add("--gameDir"); argumentList.add(gameDir.getPath()); } if (assetsDir != null) { argumentList.add("--assetsDir"); argumentList.add(assetsDir.getPath()); } argumentList.add("--version"); argumentList.add(version); argumentList.addAll(args); } return new String[0]; }
Example #14
Source File: ClassTweaker.java From The-5zig-Mod with MIT License | 6 votes |
@Override public String[] getLaunchArguments() { ArrayList<String> argumentList = (ArrayList<String>) Launch.blackboard.get("ArgumentList"); if (argumentList.isEmpty()) { if (gameDir != null) { argumentList.add("--gameDir"); argumentList.add(gameDir.getPath()); } if (assetsDir != null) { argumentList.add("--assetsDir"); argumentList.add(assetsDir.getPath()); } argumentList.add("--version"); argumentList.add(version); argumentList.addAll(args); } return new String[0]; }
Example #15
Source File: ClassTweaker.java From The-5zig-Mod with MIT License | 6 votes |
@Override public String[] getLaunchArguments() { ArrayList<String> argumentList = (ArrayList<String>) Launch.blackboard.get("ArgumentList"); if (argumentList.isEmpty()) { if (gameDir != null) { argumentList.add("--gameDir"); argumentList.add(gameDir.getPath()); } if (assetsDir != null) { argumentList.add("--assetsDir"); argumentList.add(assetsDir.getPath()); } argumentList.add("--version"); argumentList.add(version); argumentList.addAll(args); } return new String[0]; }
Example #16
Source File: MixinServiceLaunchWrapper.java From Mixin with MIT License | 6 votes |
@Override public Collection<ITransformer> getTransformers() { List<IClassTransformer> transformers = Launch.classLoader.getTransformers(); List<ITransformer> wrapped = new ArrayList<ITransformer>(transformers.size()); for (IClassTransformer transformer : transformers) { if (transformer instanceof ITransformer) { wrapped.add((ITransformer)transformer); } else { wrapped.add(new LegacyTransformerHandle(transformer)); } if (transformer instanceof IClassNameTransformer) { MixinServiceAbstract.logger.debug("Found name transformer: {}", transformer.getClass().getName()); this.nameTransformer = (IClassNameTransformer)transformer; } } return wrapped; }
Example #17
Source File: ClassTweaker.java From The-5zig-Mod with MIT License | 6 votes |
@Override public String[] getLaunchArguments() { ArrayList<String> argumentList = (ArrayList<String>) Launch.blackboard.get("ArgumentList"); if (argumentList.isEmpty()) { if (gameDir != null) { argumentList.add("--gameDir"); argumentList.add(gameDir.getPath()); } if (assetsDir != null) { argumentList.add("--assetsDir"); argumentList.add(assetsDir.getPath()); } argumentList.add("--version"); argumentList.add(version); argumentList.addAll(args); } return new String[0]; }
Example #18
Source File: ClassTweaker.java From The-5zig-Mod with MIT License | 6 votes |
@Override public String[] getLaunchArguments() { ArrayList<String> argumentList = (ArrayList<String>) Launch.blackboard.get("ArgumentList"); if (argumentList.isEmpty()) { if (gameDir != null) { argumentList.add("--gameDir"); argumentList.add(gameDir.getPath()); } if (assetsDir != null) { argumentList.add("--assetsDir"); argumentList.add(assetsDir.getPath()); } argumentList.add("--version"); argumentList.add(version); argumentList.addAll(args); } return new String[0]; }
Example #19
Source File: ClassTweaker.java From The-5zig-Mod with MIT License | 6 votes |
@Override public String[] getLaunchArguments() { ArrayList<String> argumentList = (ArrayList<String>) Launch.blackboard.get("ArgumentList"); if (argumentList.isEmpty()) { if (gameDir != null) { argumentList.add("--gameDir"); argumentList.add(gameDir.getPath()); } if (assetsDir != null) { argumentList.add("--assetsDir"); argumentList.add(assetsDir.getPath()); } argumentList.add("--version"); argumentList.add(version); argumentList.addAll(args); } return new String[0]; }
Example #20
Source File: ClassTweaker.java From The-5zig-Mod with MIT License | 6 votes |
@Override public String[] getLaunchArguments() { ArrayList<String> argumentList = (ArrayList<String>) Launch.blackboard.get("ArgumentList"); if (argumentList.isEmpty()) { if (gameDir != null) { argumentList.add("--gameDir"); argumentList.add(gameDir.getPath()); } if (assetsDir != null) { argumentList.add("--assetsDir"); argumentList.add(assetsDir.getPath()); } argumentList.add("--version"); argumentList.add(version); argumentList.addAll(args); } return new String[0]; }
Example #21
Source File: ClassTweaker.java From The-5zig-Mod with MIT License | 5 votes |
@Override public String[] getLaunchArguments() { ArrayList<String> argumentList = (ArrayList<String>) Launch.blackboard.get("ArgumentList"); if (argumentList.isEmpty()) { if (gameDir != null) { argumentList.add("--gameDir"); argumentList.add(gameDir.getPath()); } if (assetsDir != null) { argumentList.add("--assetsDir"); argumentList.add(assetsDir.getPath()); } argumentList.add("--version"); argumentList.add(version); argumentList.addAll(args); } return new String[0]; }
Example #22
Source File: MixinPlatformAgentFMLLegacy.java From Mixin with MIT License | 5 votes |
@Override public void inject() { if (this.coreModWrapper != null && this.checkForCoInitialisation()) { MixinPlatformAgentAbstract.logger.debug("FML agent is co-initiralising coremod instance {} for {}", this.coreModWrapper, this.handle); this.coreModWrapper.injectIntoClassLoader(Launch.classLoader); } }
Example #23
Source File: ClassTweaker.java From The-5zig-Mod with MIT License | 5 votes |
@Override public String[] getLaunchArguments() { ArrayList<String> argumentList = (ArrayList<String>) Launch.blackboard.get("ArgumentList"); if (argumentList.isEmpty()) { if (gameDir != null) { argumentList.add("--gameDir"); argumentList.add(gameDir.getPath()); } if (assetsDir != null) { argumentList.add("--assetsDir"); argumentList.add(assetsDir.getPath()); } argumentList.add("--version"); argumentList.add(version); argumentList.addAll(args); } return new String[0]; }
Example #24
Source File: MixinServiceLaunchWrapper.java From Mixin with MIT License | 5 votes |
@Override public boolean isValid() { try { // Detect launchwrapper Launch.classLoader.hashCode(); } catch (Throwable ex) { return false; } return true; }
Example #25
Source File: DelegatedTransformer.java From CodeChickenCore with MIT License | 5 votes |
private static void defineDependancies(byte[] bytes, JarFile jar, File jarFile, Stack<String> depStack) throws Exception { ClassReader reader = new ClassReader(bytes); DependancyLister lister = new DependancyLister(Opcodes.ASM4); reader.accept(lister, 0); depStack.push(reader.getClassName()); for(String dependancy : lister.getDependancies()) { if(depStack.contains(dependancy)) continue; try { Launch.classLoader.loadClass(dependancy.replace('/', '.')); } catch(ClassNotFoundException cnfe) { ZipEntry entry = jar.getEntry(dependancy+".class"); if(entry == null) throw new Exception("Dependency "+dependancy+" not found in jar file "+jarFile.getName()); byte[] depbytes = readFully(jar.getInputStream(entry)); defineDependancies(depbytes, jar, jarFile, depStack); logger.debug("Defining dependancy: "+dependancy); defineClass(dependancy.replace('/', '.'), depbytes); } } depStack.pop(); }
Example #26
Source File: MethodASMifier.java From CodeChickenCore with MIT License | 5 votes |
public static void printMethod(ObfMapping method, Printer printer, File toFile) { try { printMethod(method, Launch.classLoader.getClassBytes(method.javaClass()), printer, toFile); } catch (Exception e) { e.printStackTrace(); } }
Example #27
Source File: MCPDeobfuscationTransformer.java From CodeChickenCore with MIT License | 5 votes |
@Override public List<String> getParents(ObfuscationEntry desc) { try { String name = ObfMapping.obfuscated ? desc.obf.s_owner : desc.mcp.s_owner; name = name.replace('/', '.'); byte[] bytes = Launch.classLoader.getClassBytes(name); if (bytes != null) return ObfuscationRun.getParents(ASMHelper.createClassNode(bytes)); } catch (IOException e) { } return null; }
Example #28
Source File: InterfaceDependancyTransformer.java From CodeChickenCore with MIT License | 5 votes |
@Override public byte[] transform(String name, String tname, byte[] bytes) { if (bytes == null) return null; ClassNode cnode = ASMHelper.createClassNode(bytes); boolean hasDependancyInterfaces = false; if (cnode.visibleAnnotations != null) for (AnnotationNode ann : cnode.visibleAnnotations) if (ann.desc.equals(Type.getDescriptor(InterfaceDependancies.class))) { hasDependancyInterfaces = true; break; } if (!hasDependancyInterfaces) return bytes; hasDependancyInterfaces = false; for (Iterator<String> iterator = cnode.interfaces.iterator(); iterator.hasNext(); ) { try { Launch.classLoader.findClass(new ObfMapping(iterator.next()).toRuntime().javaClass()); } catch (ClassNotFoundException cnfe) { iterator.remove(); hasDependancyInterfaces = true; } } if (!hasDependancyInterfaces) return bytes; return ASMHelper.createBytes(cnode, 0); }
Example #29
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]); } }
Example #30
Source File: MixinServiceLaunchWrapper.java From Mixin with MIT License | 5 votes |
private void findNameTransformer() { List<IClassTransformer> transformers = Launch.classLoader.getTransformers(); for (IClassTransformer transformer : transformers) { if (transformer instanceof IClassNameTransformer) { MixinServiceAbstract.logger.debug("Found name transformer: {}", transformer.getClass().getName()); this.nameTransformer = (IClassNameTransformer) transformer; } } }