private static void sortTweakers() { TaskProfiler profiler = new TaskProfiler(); profiler.startOnce("Tweak Sorting."); LogHelper.info("Sorting tweakers.."); for (TGameTweak tweak : allTweakers) { LogHelper.debug("Attempting registration of tweaker \"%s\"...", tweak.getTweakName()); if (tweak instanceof TSideTweak) { if (!FMLLaunchHandler.side().equals(((TSideTweak) tweak).getSide())) { LogHelper.info("Tweaker \"%s\" will NOT be loaded as it is only for %s side!", tweak.getTweakName(), ((TSideTweak) tweak).getSide().toString()); continue; } } if (tweak.isEnabled()) { activeTweakers.add(tweak); LogHelper.debug("Successfully registered Tweaker \"%s\"!", tweak.getTweakName()); } } TaskProfiler.ProfilerResult result = profiler.endOnce(); LogHelper.info("Tweaker sorting successfully found %s enabled tweakers in %sMs.", activeTweakers.size(), TimeUnit.NANOSECONDS.toMillis(result.time)); }
@Override public void injectIntoClassLoader(LaunchClassLoader classLoader) { // The log4j2 queue is excluded so it is correctly visible from the obfuscated // and deobfuscated parts of the code. Without, the UI won't show anything classLoader.addClassLoaderExclusion("com.mojang.util.QueueLogAppender"); classLoader.addClassLoaderExclusion("jline."); classLoader.addClassLoaderExclusion("org.fusesource."); classLoader.addClassLoaderExclusion("net.minecraftforge.server.console.TerminalConsoleAppender"); FMLLaunchHandler.configureForServerLaunch(classLoader, this); FMLLaunchHandler.appendCoreMods(); }
@Override public Certificate getSigningCertificate() { if (FMLLaunchHandler.side() != Side.CLIENT) return null; try { Class<?> cbr = Class.forName("net.minecraft.client.ClientBrandRetriever", false, getClass().getClassLoader()); Certificate[] certificates = cbr.getProtectionDomain().getCodeSource().getCertificates(); return certificates != null ? certificates[0] : null; } catch (Exception e){} // Errors don't matter just return null. return null; }
@Override public void injectData(Map<String, Object> data) { liveEnv = (Boolean)data.get("runtimeDeobfuscationEnabled"); cl = (LaunchClassLoader) data.get("classLoader"); File mcDir = (File)data.get("mcLocation"); fmlLocation = (File)data.get("coremodLocation"); ClassPatchManager.INSTANCE.setup(FMLLaunchHandler.side()); FMLDeobfuscatingRemapper.INSTANCE.setup(mcDir, cl, (String) data.get("deobfuscationFileName")); }
@Override public byte[] transform(String name, String tname, byte[] bytes) { if (bytes == null) return null; try { if (FMLLaunchHandler.side().isClient()) bytes = transformSubclasses(name, bytes); bytes = transformer.transform(name, bytes); } catch (Exception e) { throw new RuntimeException(e); } return bytes; }
@Override public byte[] transform(String name, String transformedName, byte[] bytes) { if (FMLLaunchHandler.side().isClient() && transformedName.equals(TARGET_CLASS_NAME2)) { return transFormMethod(bytes); } return bytes; }
@Override public void injectIntoClassLoader(LaunchClassLoader classLoader) { FMLLaunchHandler.configureForClientLaunch(classLoader, this); FMLLaunchHandler.appendCoreMods(); }
@Override public IMessage handleClientMessage(TileDataSync message, MessageContext ctx) { if(FMLLaunchHandler.side().isClient()) message.sendToClassHandler(); return null; }
public static Side runtimeSide() { return FMLLaunchHandler.side(); }