update tiny-remapper, Mixin
This commit is contained in:
		
							parent
							
								
									bcae78333d
								
							
						
					
					
						commit
						bed0bba2da
					
				
					 5 changed files with 45 additions and 44 deletions
				
			
		|  | @ -37,12 +37,12 @@ dependencies { | |||
| 	implementation ('net.fabricmc:stitch:0.1.2.49') { | ||||
| 		exclude module: 'enigma' | ||||
| 	} | ||||
| 	implementation ('net.fabricmc:tiny-remapper:0.1.0.29') { | ||||
| 	implementation ('net.fabricmc:tiny-remapper:0.1.0.33') { | ||||
| 		transitive = false | ||||
| 	} | ||||
| 	implementation ('org.jetbrains:intellij-fernflower:1.0.0.8') | ||||
| 
 | ||||
| 	implementation ('net.fabricmc:sponge-mixin:0.7.11.21') { | ||||
| 	implementation ('net.fabricmc:sponge-mixin:0.7.11.22') { | ||||
| 		exclude module: 'launchwrapper' | ||||
| 		exclude module: 'guava' | ||||
| 	} | ||||
|  |  | |||
|  | @ -24,17 +24,16 @@ | |||
| 
 | ||||
| package net.fabricmc.loom.mixin; | ||||
| 
 | ||||
| import net.fabricmc.tinyremapper.TinyUtils; | ||||
| import net.fabricmc.mappings.*; | ||||
| import org.spongepowered.asm.obfuscation.mapping.common.MappingField; | ||||
| import org.spongepowered.asm.obfuscation.mapping.common.MappingMethod; | ||||
| import org.spongepowered.tools.obfuscation.mapping.common.MappingProvider; | ||||
| 
 | ||||
| import javax.annotation.processing.Filer; | ||||
| import javax.annotation.processing.Messager; | ||||
| import java.io.BufferedReader; | ||||
| import java.io.File; | ||||
| import java.io.FileInputStream; | ||||
| import java.io.IOException; | ||||
| import java.nio.file.Files; | ||||
| 
 | ||||
| public class MixinMappingProviderTiny extends MappingProvider { | ||||
| 	private final String from, to; | ||||
|  | @ -119,22 +118,36 @@ public class MixinMappingProviderTiny extends MappingProvider { | |||
| 		} */ | ||||
| 	} | ||||
| 
 | ||||
| 	// TODO: Unify with tiny-remapper | ||||
| 
 | ||||
| 	@Override | ||||
| 	public void read(File input) throws IOException { | ||||
| 		BufferedReader reader = Files.newBufferedReader(input.toPath()); | ||||
| 		Mappings mappings; | ||||
| 
 | ||||
| 		try (FileInputStream stream = new FileInputStream(input)) { | ||||
| 			mappings = MappingsProvider.readTinyMappings(stream, false); | ||||
| 		} | ||||
| 
 | ||||
| 		for (ClassEntry entry : mappings.getClassEntries()) { | ||||
| 			classMap.put(entry.get(from), entry.get(to)); | ||||
| 		} | ||||
| 
 | ||||
| 		for (FieldEntry entry : mappings.getFieldEntries()) { | ||||
| 			EntryTriple fromEntry = entry.get(from); | ||||
| 			EntryTriple toEntry = entry.get(to); | ||||
| 
 | ||||
| 		TinyUtils.read(reader, from, to, classMap::put, (fieldFrom, fieldTo) -> { | ||||
| 			fieldMap.put( | ||||
| 				new MappingField(fieldFrom.owner, fieldFrom.name, fieldFrom.desc), | ||||
| 				new MappingField(fieldTo.owner, fieldTo.name, fieldTo.desc) | ||||
| 					new MappingField(fromEntry.getOwner(), fromEntry.getName(), fromEntry.getDesc()), | ||||
| 					new MappingField(toEntry.getOwner(), toEntry.getName(), toEntry.getDesc()) | ||||
| 			); | ||||
| 		}, (methodFrom, methodTo) -> { | ||||
| 		} | ||||
| 
 | ||||
| 		for (MethodEntry entry : mappings.getMethodEntries()) { | ||||
| 			EntryTriple fromEntry = entry.get(from); | ||||
| 			EntryTriple toEntry = entry.get(to); | ||||
| 
 | ||||
| 			methodMap.put( | ||||
| 				new MappingMethod(methodFrom.owner, methodFrom.name, methodFrom.desc), | ||||
| 				new MappingMethod(methodTo.owner, methodTo.name, methodTo.desc) | ||||
| 					new MappingMethod(fromEntry.getOwner(), fromEntry.getName(), fromEntry.getDesc()), | ||||
| 					new MappingMethod(toEntry.getOwner(), toEntry.getName(), toEntry.getDesc()) | ||||
| 			); | ||||
| 		}); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -69,9 +69,9 @@ public class MapJarsTiny { | |||
| 
 | ||||
| 			try (OutputConsumerPath outputConsumer = new OutputConsumerPath(output)) { | ||||
| 				outputConsumer.addNonClassFiles(input); | ||||
| 				remapper.read(input); | ||||
| 				remapper.read(classpath); | ||||
| 				remapper.apply(input, outputConsumer); | ||||
| 				remapper.readClassPath(classpath); | ||||
| 				remapper.readInputs(input); | ||||
| 				remapper.apply(outputConsumer); | ||||
| 			} catch (Exception e) { | ||||
| 				throw new RuntimeException("Failed to remap JAR", e); | ||||
| 			} finally { | ||||
|  |  | |||
|  | @ -148,8 +148,8 @@ public class ModProcessor { | |||
| 		Path[] mcDeps = mappedProvider.getMapperPaths().stream() | ||||
| 			.map(File::toPath) | ||||
| 			.toArray(Path[]::new); | ||||
| 		Collection<File> modCompileFiles = project.getConfigurations().getByName(Constants.COMPILE_MODS).getFiles(); | ||||
| 		Path[] modCompiles = modCompileFiles.stream() | ||||
| 		Path[] modCompiles = project.getConfigurations().getByName(Constants.COMPILE_MODS).getFiles().stream() | ||||
| 				.filter((f) -> !f.equals(input)) | ||||
| 				.map(p -> { | ||||
| 					if (p.equals(input)) { | ||||
| 						return inputPath; | ||||
|  | @ -167,13 +167,11 @@ public class ModProcessor { | |||
| 
 | ||||
| 		try (OutputConsumerPath outputConsumer = new OutputConsumerPath(Paths.get(output.getAbsolutePath()))) { | ||||
| 			outputConsumer.addNonClassFiles(inputPath); | ||||
| 			if (!modCompileFiles.contains(input)) { | ||||
| 				remapper.read(inputPath); | ||||
| 			} | ||||
| 			remapper.read(modCompiles); | ||||
| 			remapper.read(mc); | ||||
| 			remapper.read(mcDeps); | ||||
| 			remapper.apply(inputPath, outputConsumer); | ||||
| 			remapper.readClassPath(modCompiles); | ||||
| 			remapper.readClassPath(mc); | ||||
| 			remapper.readClassPath(mcDeps); | ||||
| 			remapper.readInputs(inputPath); | ||||
| 			remapper.apply(outputConsumer); | ||||
| 		} catch (Exception e){ | ||||
| 			throw new RuntimeException("Failed to remap JAR to " + toM, e); | ||||
| 		} finally { | ||||
|  |  | |||
|  | @ -37,6 +37,7 @@ import java.io.File; | |||
| import java.io.IOException; | ||||
| import java.nio.file.Path; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
| 
 | ||||
| public class ModRemapper { | ||||
|  | @ -62,19 +63,10 @@ public class ModRemapper { | |||
| 		List<File> classpathFiles = new ArrayList<>(); | ||||
| 		classpathFiles.addAll(project.getConfigurations().getByName(Constants.COMPILE_MODS_MAPPED).getFiles()); | ||||
| 		classpathFiles.addAll(project.getConfigurations().getByName(Constants.MINECRAFT_NAMED).getFiles()); | ||||
| 		Path[] classpath = classpathFiles.stream().map(File::toPath).toArray(Path[]::new); | ||||
| 		Path modJarPath = modJar.toPath(); | ||||
| 		boolean classpathContainsModJarPath = false; | ||||
| 		final Path modJarPath = modJar.toPath(); | ||||
| 		Path[] classpath = classpathFiles.stream().map(File::toPath).filter((p) -> !modJarPath.equals(p)).toArray(Path[]::new); | ||||
| 
 | ||||
| 		for (Path p : classpath) { | ||||
| 			if (modJarPath.equals(p)) { | ||||
| 				modJarPath = p; | ||||
| 				classpathContainsModJarPath = true; | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		String s =modJar.getAbsolutePath(); | ||||
| 		String s = modJar.getAbsolutePath(); | ||||
| 		File modJarOutput = new File(s.substring(0, s.length() - 4) + ".remapped.jar"); | ||||
| 		Path modJarOutputPath = modJarOutput.toPath(); | ||||
| 
 | ||||
|  | @ -98,11 +90,9 @@ public class ModRemapper { | |||
| 
 | ||||
| 		try (OutputConsumerPath outputConsumer = new OutputConsumerPath(modJarOutputPath)) { | ||||
| 			outputConsumer.addNonClassFiles(modJarPath); | ||||
| 			remapper.read(classpath); | ||||
| 			if (!classpathContainsModJarPath) { | ||||
| 				remapper.read(modJarPath); | ||||
| 			} | ||||
| 			remapper.apply(modJarPath, outputConsumer); | ||||
| 			remapper.readClassPath(classpath); | ||||
| 			remapper.readInputs(modJarPath); | ||||
| 			remapper.apply(outputConsumer); | ||||
| 		} catch (Exception e) { | ||||
| 			throw new RuntimeException("Failed to remap JAR", e); | ||||
| 		} finally { | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue