diff --git a/build.gradle b/build.gradle index db061148f..8c3a8adf6 100644 --- a/build.gradle +++ b/build.gradle @@ -20,9 +20,10 @@ import net.minecraftforge.gradle.common.task.ArchiveChecksum import net.minecraftforge.gradle.common.task.DownloadMavenArtifact import net.minecraftforge.gradle.common.task.SignJar import net.minecraftforge.gradle.patcher.task.ApplyBinPatches +import net.minecraftforge.gradle.patcher.task.TaskReobfuscateJar +import net.minecraftforge.gradle.userdev.tasks.RenameJar import org.apache.tools.ant.filters.ReplaceTokens import de.undercouch.gradle.tasks.download.Download -import net.minecraftforge.gradle.patcher.task.TaskReobfuscateJar import org.gradle.plugins.ide.eclipse.model.SourceFolder import java.util.stream.Collectors @@ -174,6 +175,7 @@ project(':forge') { // ForgeMC is a unique identifier for every MC version we have supported. // Essentially, the same as the old, except dropping the first number, and the builds are no longer unique. MCP_ARTIFACT = project(':mcp').mcp.config + SPECIAL_SOURCE = 'net.md-5:SpecialSource:1.8.5' } def getVersion = { @@ -457,6 +459,21 @@ project(':forge') { clean = { genJoinedBinPatches.cleanJar } input = genJoinedBinPatches.output } + // Create SRG named Vanilla jars, using the SpecialSource we have in the installer + task createClientSRG(type: RenameJar, dependsOn: genClientBinPatches) { + tool = SPECIAL_SOURCE + ':shaded' + args = ['--stable', '--in-jar', '{input}', '--out-jar', '{output}', '--srg-in', '{mappings}'] + mappings = { genClientBinPatches.srg } + input = { genClientBinPatches.cleanJar } + output = file('build/createClientSRG/output.jar') + } + task createServerSRG(type: RenameJar, dependsOn: genServerBinPatches) { + tool = SPECIAL_SOURCE + ':shaded' + args = ['--stable', '--in-jar', '{input}', '--out-jar', '{output}', '--srg-in', '{mappings}'] + mappings = { genServerBinPatches.srg } + input = { genServerBinPatches.cleanJar } + output = file('build/createServerSRG/output.jar') + } // Checksum tasks so that we can know if the vanilla classes are what we expect them to do! task clientBaseChecksum(type: ArchiveChecksum, dependsOn: genClientBinPatches) { input = { genClientBinPatches.cleanJar} //Lazy because Patcher Plugin sets the value afterEvaluate @@ -502,6 +519,7 @@ project(':forge') { task launcherJson(dependsOn: ['signUniversalJar', 'signLauncherJar']) { inputs.file universalJar.archivePath + inputs.file { launcherJar.archivePath } ext { output = file('build/version.json') vanilla = project(':mcp').file('build/mcp/downloadJson/version.json') @@ -555,10 +573,10 @@ project(':forge') { } } - task installerJson(dependsOn: [launcherJson, genClientBinPatches, applyClientBinPatches, applyServerBinPatches]) { + task installerJson(dependsOn: [launcherJson, genClientBinPatches, applyClientBinPatches, applyServerBinPatches/*, createClientSRG, createServerSRG*/]) { ext { output = file('build/install_profile.json') - INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.0.3' + INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.1.1' JAR_SPLITTER = 'net.minecraftforge:jarsplitter:1.1.0' } doFirst { @@ -568,6 +586,10 @@ project(':forge') { inputs.file applyServerBinPatches.output inputs.file genClientBinPatches.toolJar inputs.file launcherJson.output + /* + inputs.file createClientSRG.output + inputs.file createServerSRG.output + */ outputs.file output doLast { def libs = [ @@ -622,6 +644,10 @@ project(':forge') { client: "[net.minecraft:client:${MC_VERSION}-${MCP_VERSION}:srg]", server: "[net.minecraft:server:${MC_VERSION}-${MCP_VERSION}:srg]" ], + /*MC_SRG_SHA: [ + client: "'${sha1(createClientSRG.output)}'", + server: "'${sha1(createServerSRG.output)}'" + ],*/ PATCHED: [ client: "[${project.group}:${project.name}:${project.version}:client]", server: "[${project.group}:${project.name}:${project.version}:server]" @@ -629,6 +655,10 @@ project(':forge') { PATCHED_SHA: [ client: "'${sha1(applyClientBinPatches.output)}'", server: "'${sha1(applyServerBinPatches.output)}'" + ], + MCP_VERSION: [ + client: "'${MCP_VERSION}'", + server: "'${MCP_VERSION}'" ] ], processors: [ @@ -654,21 +684,19 @@ project(':forge') { '{MC_SLIM}': '{MC_SLIM_SHA}', '{MC_EXTRA}': '{MC_EXTRA_SHA}' ] - ], [ // SpecialSource has a bug where it won't create the nessasary directories, remove when they fix that. - jar: INSTALLER_TOOLS, - classpath: getClasspath(project, libs, INSTALLER_TOOLS), - args: [ - '--task', 'CREATE_PARENTS', - '--target', '{MC_SRG}' - ] ], [ - jar: 'net.md-5:SpecialSource:1.8.3', - classpath: getClasspath(project, libs, 'net.md-5:SpecialSource:1.8.3'), + jar: SPECIAL_SOURCE, + classpath: getClasspath(project, libs, SPECIAL_SOURCE), args: [ + //'--stable', Java 9 Is borked, https://bugs.openjdk.java.net/browse/JDK-8184940 TODO: find a fix. '--in-jar', '{MC_SLIM}', '--out-jar', '{MC_SRG}', '--srg-in', '{MAPPINGS}' + ]/*, + outputs: [ + '{MC_SRG}': '{MC_SRG_SHA}' ] + */ ], [ jar: BIN_PATCHER, classpath: getClasspath(project, libs, BIN_PATCHER), @@ -680,6 +708,15 @@ project(':forge') { outputs: [ '{PATCHED}': '{PATCHED_SHA}' ] + ], [ + jar: INSTALLER_TOOLS, + classpath: getClasspath(project, libs, INSTALLER_TOOLS), + args: [ + '--task', 'DEOBF_REALMS', + '--map', '{MAPPINGS}', + '--mc', '{MINECRAFT_JAR}', + '--mcp', '{MCP_VERSION}' + ] ] ] ] @@ -711,6 +748,7 @@ project(':forge') { dependsOn fixAnnotationsJson */ + /* We do not actually check this anywhere, so it's 400KB of uselless data // Add checksum files of clean and patched vanilla classes. ['client', 'server'].each { side -> ['Base', 'Patched'].each { type -> @@ -720,6 +758,7 @@ project(':forge') { } } dependsOn checksums + */ // add crowdin locales from { !crowdin.state.skipped ? zipTree(crowdin.archivePath) : null} diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLClientLaunchProvider.java b/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLClientLaunchProvider.java index 282688076..825a056d9 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLClientLaunchProvider.java +++ b/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLClientLaunchProvider.java @@ -27,11 +27,16 @@ import net.minecraftforge.api.distmarker.Dist; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.Callable; +import static net.minecraftforge.fml.loading.LogMarkers.CORE; + public class FMLClientLaunchProvider extends FMLCommonLaunchHandler implements ILaunchHandlerService { private static final Logger LOGGER = LogManager.getLogger(); @@ -57,7 +62,10 @@ public class FMLClientLaunchProvider extends FMLCommonLaunchHandler implements I public void configureTransformationClassLoader(final ITransformingClassLoaderBuilder builder) { super.configureTransformationClassLoader(builder); - builder.addTransformationPath(LibraryFinder.findJarPathFor("com/mojang/realmsclient/plugin/RealmsPluginImpl.class", "realms")); + Path realms = LibraryFinder.findJarPathFor("com/mojang/realmsclient/plugin/RealmsPluginImpl.class", "realms"); + Path mapped = Paths.get(realms.toString().substring(0, realms.toString().length() - 4) + '-' + FMLLoader.getMcpVersion() + ".jar"); + LOGGER.debug(CORE, "Found realms library at {}", Files.exists(mapped) ? mapped : realms); + builder.addTransformationPath(Files.exists(mapped) ? mapped : realms); } @SuppressWarnings("unchecked") diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLLoader.java b/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLLoader.java index ff39c52cc..96899e2a0 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLLoader.java +++ b/src/fmllauncher/java/net/minecraftforge/fml/loading/FMLLoader.java @@ -264,4 +264,8 @@ public class FMLLoader public static Optional> getNameFunction(final String naming) { return Launcher.INSTANCE.environment().findNameMapping(naming); } + + public static String getMcpVersion() { + return mcpVersion; + } } diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/StringSubstitutor.java b/src/fmllauncher/java/net/minecraftforge/fml/loading/StringSubstitutor.java index f09c7a8b7..943c40240 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/StringSubstitutor.java +++ b/src/fmllauncher/java/net/minecraftforge/fml/loading/StringSubstitutor.java @@ -24,10 +24,9 @@ import net.minecraftforge.fml.loading.moddiscovery.ModFile; import org.apache.commons.lang3.text.StrLookup; import org.apache.commons.lang3.text.StrSubstitutor; -import java.util.Arrays; -import java.util.List; import java.util.Map; +@SuppressWarnings("deprecation") public class StringSubstitutor { private static final Map globals = ImmutableMap.of(