Skip to content

Commit

Permalink
"working" (wrong checksum)
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Dec 11, 2021
1 parent 8efcf91 commit ccb215d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 15 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ repositories {
excludeGroupByRegex "org\\.eclipse\\.?.*"
}
}
maven { url "https://jitpack.io" }
mavenLocal()
}

Expand Down Expand Up @@ -113,7 +114,7 @@ dependencies {

// Forge patches
implementation ('net.minecraftforge:installertools:1.2.0')
implementation ('net.minecraftforge:binarypatcher:1.1.1')
implementation ('com.github.wagyourtail:BinaryPatcher:383bae7aa3')
implementation ('org.cadixdev:lorenz:0.5.3')
implementation ('org.cadixdev:lorenz-asm:0.5.3')
implementation ('de.oceanlabs.mcp:mcinjector:3.8.0')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public void provide(DependencyInfo dependency, Consumer<Runnable> postPopulation
mappingsPath = ZipUtils.contains(mcpZip, "joined.srg") ? "joined.srg" : "config/joined.tsrg";
isSRG = mappingsPath.endsWith(".srg");
remapAction = new FG2RemapAction(getProject());
if (!Files.exists(mcp) || isRefreshDeps()) {
Files.copy(mcpZip, mcp, StandardCopyOption.REPLACE_EXISTING);
}
return;
}

Expand Down Expand Up @@ -172,7 +175,7 @@ public static class FG2RemapAction implements RemapAction {

public FG2RemapAction(Project project) {
this.project = project;
this.name = "net.md-5:SpecialSource:1.8.3:shaded";
this.name = "net.md-5:SpecialSource:1.7.4:shaded";
this.mainClasspath = DependencyDownloader.download(project, this.name, false, true)
.getSingleFile();
this.classpath = DependencyDownloader.download(project, this.name, true, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,17 @@ private void createSrgJars(Logger logger) throws Exception {
produceSrgJar(getExtension().isForgeAndOfficial(), minecraftProvider.minecraftClientJar.toPath(), minecraftProvider.getMinecraftServerJar().toPath());
}

private void produceSrgJar(boolean official, Path clientJar, Path serverJar) throws IOException {
private void produceSrgJar(boolean official, Path clientJar, Path serverJar) throws Exception {
Path tmpSrg = getToSrgMappings();
Set<File> mcLibs = getProject().getConfigurations().getByName(Constants.Configurations.MINECRAFT_DEPENDENCIES).resolve();

ThreadingUtils.run(() -> {
Files.copy(SpecialSourceExecutor.produceSrgJar(getExtension().getMcpConfigProvider().getRemapAction(), getProject(), "client", mcLibs, clientJar, tmpSrg), minecraftClientSrgJar.toPath());
}, () -> {
Files.copy(SpecialSourceExecutor.produceSrgJar(getExtension().getMcpConfigProvider().getRemapAction(), getProject(), "server", mcLibs, serverJar, tmpSrg), minecraftServerSrgJar.toPath());
});
boolean isSrg = getExtension().getMcpConfigProvider().isSRG();

// ThreadingUtils.run(() -> {
Files.copy(SpecialSourceExecutor.produceSrgJar(getExtension().getMcpConfigProvider().getRemapAction(), getProject(), "client", mcLibs, clientJar, tmpSrg, isSrg), minecraftClientSrgJar.toPath());
// }, () -> {
Files.copy(SpecialSourceExecutor.produceSrgJar(getExtension().getMcpConfigProvider().getRemapAction(), getProject(), "server", mcLibs, serverJar, tmpSrg, isSrg), minecraftServerSrgJar.toPath());
// });
}

private Path getToSrgMappings() throws IOException {
Expand Down Expand Up @@ -605,7 +607,9 @@ private void patchJars(Logger logger) throws IOException {

PatchProvider patchProvider = getExtension().getPatchProvider();
patchJars(minecraftClientSrgJar, minecraftClientPatchedSrgJar, patchProvider.clientPatches);
patchJars(minecraftServerSrgJar, minecraftServerPatchedSrgJar, patchProvider.serverPatches);
if (!getExtension().getMcpConfigProvider().isSRG()) {
patchJars(minecraftServerSrgJar, minecraftServerPatchedSrgJar, patchProvider.serverPatches);
}

ThreadingUtils.run(Environment.values(), environment -> {
copyMissingClasses(environment.srgJar.apply(this), environment.patchedSrgJar.apply(this));
Expand All @@ -628,12 +632,22 @@ private void patchJars(File clean, File output, Path patches) throws IOException
// Failed to replace logger filter, just ignore
}

ConsoleTool.main(new String[] {
if (getExtension().getMcpConfigProvider().isSRG()) {

ConsoleTool.main(new String[] {
"--clean", clean.getAbsolutePath(),
"--output", output.getAbsolutePath(),
"--apply", patches.toAbsolutePath().toString(),
"--pack200"
});
"--legacy"
});

} else {
ConsoleTool.main(new String[] {
"--clean", clean.getAbsolutePath(),
"--output", output.getAbsolutePath(),
"--apply", patches.toAbsolutePath().toString()
});
}

try {
System.setOut(previous);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,30 @@ private static String trimLeadingSlash(String string) {
return string;
}

public static Path produceSrgJar(RemapAction remapAction, Project project, String side, Set<File> mcLibs, Path officialJar, Path mappings)
public static Path produceSrgJar(RemapAction remapAction, Project project, String side, Set<File> mcLibs, Path officialJar, Path mappings, boolean isSrg)
throws Exception {
Set<String> filter = Files.readAllLines(mappings, StandardCharsets.UTF_8).stream()
Set<String> filter;
if (isSrg) {
filter = Files.readAllLines(mappings, StandardCharsets.UTF_8).stream()
.filter(s -> s.startsWith("CL:"))
.map(s -> s.split(" ")[1] + ".class")
.collect(Collectors.toSet());
} else {
filter = Files.readAllLines(mappings, StandardCharsets.UTF_8).stream()
.filter(s -> !s.startsWith("\t"))
.map(s -> s.split(" ")[0] + ".class")
.collect(Collectors.toSet());
}
LoomGradleExtension extension = LoomGradleExtension.get(project.getProject());
Path stripped = extension.getFiles().getProjectBuildCache().toPath().resolve(officialJar.getFileName().toString().substring(0, officialJar.getFileName().toString().length() - 4) + "-filtered.jar");
Files.deleteIfExists(stripped);

project.getLogger().info(officialJar.toString());

Stopwatch stopwatch = Stopwatch.createStarted();

int count = 0;

try (FileSystemUtil.Delegate output = FileSystemUtil.getJarFileSystem(stripped, true)) {
try (FileSystemUtil.Delegate fs = FileSystemUtil.getJarFileSystem(officialJar, false)) {
ThreadingUtils.TaskCompleter completer = ThreadingUtils.taskCompleter();
Expand All @@ -91,18 +103,20 @@ public static Path produceSrgJar(RemapAction remapAction, Project project, Strin
completer.add(() -> {
Files.copy(path, to, StandardCopyOption.COPY_ATTRIBUTES);
});
count++;
}

completer.complete();
}
} finally {
project.getLogger().info("Copied class files in " + stopwatch.stop());
project.getLogger().info("Copied " + count + " class files in " + stopwatch.stop());
}

Path output = extension.getFiles().getProjectBuildCache().toPath().resolve(officialJar.getFileName().toString().substring(0, officialJar.getFileName().toString().length() - 4) + "-srg-output.jar");
Files.deleteIfExists(output);
stopwatch = Stopwatch.createStarted();

project.getLogger().info(stripped.toString());
List<String> args = remapAction.getArgs(stripped, output, mappings, project.files(mcLibs));

project.getLogger().lifecycle(":remapping minecraft (" + remapAction + ", " + side + ", official -> mojang)");
Expand Down

0 comments on commit ccb215d

Please sign in to comment.