private void loadDeps() { downloadMonitor = FMLLaunchHandler.side().isClient() ? new Downloader() : new DummyDownloader(); try { while (!depSet.isEmpty()) { Iterator<String> it = depSet.iterator(); Dependency dep = depMap.get(it.next()); it.remove(); load(dep); } } finally { if (popupWindow != null) { popupWindow.setVisible(false); popupWindow.dispose(); } } }
@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 void injectIntoClassLoader(LaunchClassLoader classLoader) { classLoader.addClassLoaderExclusion("org.apache."); classLoader.addClassLoaderExclusion("com.google.common."); classLoader.addTransformerExclusion("cpw.mods.fml.repackage."); classLoader.addTransformerExclusion("cpw.mods.fml.relauncher."); classLoader.addTransformerExclusion("cpw.mods.fml.common.asm.transformers."); classLoader.addClassLoaderExclusion("LZMA."); FMLLaunchHandler.configureForClientLaunch(classLoader, this); FMLLaunchHandler.appendCoreMods(); }
@Override public void injectIntoClassLoader(LaunchClassLoader classLoader) { // The mojang packages are excluded so the log4j2 queue is correctly visible from // the obfuscated and deobfuscated parts of the code. Without, the UI won't show anything classLoader.addClassLoaderExclusion("com.mojang."); classLoader.addTransformerExclusion("cpw.mods.fml.repackage."); classLoader.addTransformerExclusion("cpw.mods.fml.relauncher."); classLoader.addTransformerExclusion("cpw.mods.fml.common.asm.transformers."); classLoader.addClassLoaderExclusion("LZMA."); 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 void injectData(Map<String, Object> data) { 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")); }
private void handleMethod(ClassNode classNode, String from, MethodNode mn) { if ( FMLLaunchHandler.side() == Side.SERVER && hasAnnotation( mn.visibleAnnotations, RBClientMethod.class ) ) { RBLog.info( "Skipping, method client only." ); return; } Iterator<AbstractInsnNode> i = mn.instructions.iterator(); while (i.hasNext()) { processNode( i.next(), from, classNode.name ); } for (MethodNode tmn : classNode.methods) { if ( tmn.name.equals( mn.name ) && tmn.desc.equals( mn.desc ) ) { RBLog.info( "Found " + tmn.name + " : Appending" ); AbstractInsnNode finalReturn = mn.instructions.getLast(); while (!isReturn( finalReturn.getOpcode() )) { mn.instructions.remove( finalReturn ); finalReturn = mn.instructions.getLast(); } mn.instructions.remove( finalReturn ); tmn.instructions.insert( mn.instructions ); return; } } RBLog.info( "No Such Method " + mn.name + " : Adding" ); classNode.methods.add( mn ); }
@Override public void injectIntoClassLoader(LaunchClassLoader classLoader) { classLoader.addTransformerExclusion("cpw.mods.fml.repackage."); classLoader.addTransformerExclusion("cpw.mods.fml.relauncher."); classLoader.addTransformerExclusion("cpw.mods.fml.common.asm.transformers."); classLoader.addClassLoaderExclusion("LZMA."); FMLLaunchHandler.configureForClientLaunch(classLoader, this); FMLLaunchHandler.appendCoreMods(); }
@Override public void injectIntoClassLoader(LaunchClassLoader classLoader) { classLoader.addTransformerExclusion("cpw.mods.fml.repackage."); classLoader.addTransformerExclusion("cpw.mods.fml.relauncher."); classLoader.addTransformerExclusion("cpw.mods.fml.common.asm.transformers."); classLoader.addClassLoaderExclusion("LZMA."); FMLLaunchHandler.configureForServerLaunch(classLoader, this); FMLLaunchHandler.appendCoreMods(); }
@Override public void visitMethodInsn(int opcode, String owner, String name, String desc) { super.visitMethodInsn(opcode, owner, name, desc); String teIntName = "net/minecraft/tileentity/TileEntity"; Type worldType = Type.getObjectType("net/minecraft/world/World"); if (owner.equals(teIntName) && name.equals(MCPNames.method(MCPNames.M_UPDATE_ENTITY))) { boolean client = FMLLaunchHandler.side().isClient(); Label after = new Label(); if (client) { super.visitVarInsn(ALOAD, 0); super.visitFieldInsn(GETFIELD, worldType.getInternalName(), MCPNames.field(MCPNames.F_IS_REMOTE), Type.BOOLEAN_TYPE.getDescriptor()); super.visitJumpInsn(IFNE, after); } super.visitVarInsn(ALOAD, lastLoadLocal); super.visitVarInsn(ALOAD, lastLoadLocal); super.visitFieldInsn(GETFIELD, teIntName, CompanionFieldAdder.COMPANION_FIELD, Type.getDescriptor(SyncCompanion.class)); String hookClazz = Type.getInternalName(ASMHooks.class); String invokeCheck = ASMHooks.INVOKE_SYNC_COMP_CHECK; String invokeCheckDesc = Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(Object.class), Type.getType(SyncCompanion.class)); super.visitMethodInsn(INVOKESTATIC, hookClazz, invokeCheck, invokeCheckDesc); if (client) { super.visitLabel(after); } } }
@Override public boolean shouldPatchClass() { return FMLLaunchHandler.side() != Side.CLIENT; }
@Override public String getModContainerClass() { if (FMLLaunchHandler.side() == Side.CLIENT) return JiffyDummyContainer.class.getName(); return null; }
@Override public void visitFieldInsn(int opcode, String owner, String name, String desc) { super.visitFieldInsn(opcode, owner, name, desc); String entityIntName = "net/minecraft/entity/Entity"; if (foundIAdd && owner.equals(entityIntName) && name.equals(MCPNames.field(MCPNames.F_ENTITY_TICKS_EXISTED))) { Type syncerCompanionType = Type.getType(SyncCompanion.class); Type worldType = Type.getObjectType("net/minecraft/world/World"); boolean client = FMLLaunchHandler.side().isClient(); Label after = new Label(); if (client) { super.visitVarInsn(ALOAD, 0); super.visitFieldInsn(GETFIELD, worldType.getInternalName(), MCPNames.field(MCPNames.F_IS_REMOTE), Type.BOOLEAN_TYPE.getDescriptor()); super.visitJumpInsn(IFNE, after); } super.visitVarInsn(ALOAD, 1); // entity parameter super.visitVarInsn(ALOAD, 1); super.visitFieldInsn(GETFIELD, entityIntName, CompanionFieldAdder.COMPANION_FIELD, syncerCompanionType.getDescriptor()); String hookClazz = Type.getInternalName(ASMHooks.class); String invokeCheck = ASMHooks.INVOKE_SYNC_COMP_CHECK; String invokeCheckDesc = Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(Object.class), Type.getType(SyncCompanion.class)); super.visitMethodInsn(INVOKESTATIC, hookClazz, invokeCheck, invokeCheckDesc); super.visitVarInsn(ALOAD, 1); super.visitFieldInsn(GETFIELD, entityIntName, EntitySyncPropsHooks.FIELD_NAME, Type.getDescriptor(List.class)); String tickSyncProps = ASMHooks.TICK_IEEP_COMPANIONS; String tickSyncPropsDesc = Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(List.class)); super.visitMethodInsn(INVOKESTATIC, hookClazz, tickSyncProps, tickSyncPropsDesc); if (client) { super.visitLabel(after); } done = true; } foundIAdd = false; }