Merge pull request #10 from OpenModLoader/master

Things are happening
dev/0.11
Modmuss50 2018-10-22 19:26:14 +01:00 committed by GitHub
commit 30dc5a3d35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 341 additions and 200 deletions

2
.gitignore vendored
View File

@ -16,4 +16,4 @@
!/LICENSE !/LICENSE
!/README.md !/README.md
!/settings.gradle !/settings.gradle
!/Jenkinsfile !/BuildFile

View File

@ -11,5 +11,5 @@ node {
stage "Archive artifacts" stage "Archive artifacts"
sh "./gradlew upload" sh "./gradlew publish"
} }

View File

@ -1,6 +1,6 @@
# fabric-loom # OpenGradle
Gradle plugin for Fabric Gradle plugin for OpenModLoader
Usage: `gradlew setupFabric idea` Usage: `gradlew setup idea`
(Prefix with `./` on macOS and Linux) (Use `./gradle` on macOS and Linux)

View File

@ -2,7 +2,7 @@ plugins {
id 'java' id 'java'
id 'groovy' id 'groovy'
id 'maven' id 'maven'
id 'maven-publish'
id 'idea' id 'idea'
id 'eclipse' id 'eclipse'
} }
@ -10,12 +10,9 @@ plugins {
sourceCompatibility = 1.8 sourceCompatibility = 1.8
targetCompatibility = 1.8 targetCompatibility = 1.8
apply from: 'https://github.com/FabricMC/fabric-docs/raw/master/gradle/maven.gradle'
apply from: 'https://github.com/FabricMC/fabric-docs/raw/master/gradle/license.gradle'
group = 'net.fabricmc' group = 'net.fabricmc'
archivesBaseName = project.name.toLowerCase() archivesBaseName = project.name
version = '0.0.7-SNAPSHOT' version = '0.0.12-SNAPSHOT'
repositories { repositories {
mavenCentral() mavenCentral()
@ -24,13 +21,17 @@ repositories {
url = 'http://maven.fabricmc.net/' url = 'http://maven.fabricmc.net/'
} }
maven { maven {
name "RX14 Repository" name "Modmuss"
url 'http://mvn.rx14.co.uk/local/' url 'http://maven.modmuss50.me/'
} }
maven { maven {
name = 'Mojang' name = 'Mojang'
url = 'https://libraries.minecraft.net/' url = 'https://libraries.minecraft.net/'
} }
maven {
name = 'Forge' //For ModLauncher
url = 'http://files.minecraftforge.net/maven/'
}
} }
configurations { configurations {
@ -48,14 +49,17 @@ dependencies {
shade 'com.google.code.gson:gson:2.6.2' shade 'com.google.code.gson:gson:2.6.2'
shade 'commons-io:commons-io:1.4' shade 'commons-io:commons-io:1.4'
shade 'com.google.guava:guava:19.0' shade 'com.google.guava:guava:19.0'
shade 'net.fabricmc:weave:0.1.0.+' shade ('weave-asm:weave:0.1.0.7'){
shade 'cuchaz:enigma:0.11.0.+:lib' transitive = false
shade 'net.fabricmc:tiny-remapper:+' }
shade ('enigma-asm:enigma:0.12.0.33:lib'){
exclude group: 'org.ow2.asm'
//Always fun when your dep needs the tool to build, but the tool needs the dep. }
//compile 'net.fabricmc:fabric-base:16w38a-0.0.4-SNAPSHOT' shade 'OpenModLoader.tiny-remapper:tiny-remapper:0.1.0.7'
shade 'net.sf.jopt-simple:jopt-simple:5.0.4'
shade 'org.apache.logging.log4j:log4j-api:2.11.0'
shade 'org.apache.logging.log4j:log4j-core:2.11.0'
shade 'cpw.mods:modlauncher:0.1.0-rc.3'
shade 'org.apache.commons:commons-lang3:3.5' shade 'org.apache.commons:commons-lang3:3.5'
} }
@ -68,16 +72,42 @@ sourceSets {
} }
jar { jar {
from { duplicatesStrategy = DuplicatesStrategy.EXCLUDE
configurations.shade.each { dep -> from (configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }) {
from(project.zipTree(dep)){ exclude 'META-INF/*'
exclude 'META-INF', 'META-INF/**' exclude 'META-INF'
}
}
} }
} }
task wrapper(type: Wrapper) { task wrapper(type: Wrapper) {
gradleVersion = '3.1' gradleVersion = '4.9'
}
publishing {
publications {
maven(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
from components.java
//Removes all of the dependencies from the maven pom, prevents sub projects downloading all the libs, as we use a fat jar
pom.withXml {
asNode().remove(asNode().get('dependencies'))
}
}
}
repositories {
maven {
url "http://mavenupload.modmuss50.me/"
if (project.hasProperty('mavenPass')) {
credentials {
username 'buildslave'
password project.getProperty('mavenPass')
}
}
}
}
} }

Binary file not shown.

View File

@ -1,6 +1,5 @@
#Wed May 10 22:17:52 BST 2017
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip

23
gradlew vendored
View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env sh
############################################################################## ##############################################################################
## ##
@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD="maximum"
warn ( ) { warn () {
echo "$*" echo "$*"
} }
die ( ) { die () {
echo echo
echo "$*" echo "$*"
echo echo
@ -154,16 +154,19 @@ if $cygwin ; then
esac esac
fi fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules # Escape application args
function splitJvmOpts() { save () {
JVM_OPTS=("$@") for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
} }
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS APP_ARGS=$(save "$@")
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")" cd "$(dirname "$0")"
fi fi
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" exec "$JAVACMD" "$@"

View File

@ -26,6 +26,7 @@ package net.fabricmc.loom;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.fabricmc.loom.task.DownloadTask; import net.fabricmc.loom.task.DownloadTask;
@ -85,6 +86,7 @@ public class AbstractPlugin implements Plugin<Project> {
configureIDEs(); configureIDEs();
configureCompile(); configureCompile();
} }
/** /**
@ -137,10 +139,12 @@ public class AbstractPlugin implements Plugin<Project> {
ideaModule.getModule().setDownloadSources(true); ideaModule.getModule().setDownloadSources(true);
ideaModule.getModule().setInheritOutputDirs(true); ideaModule.getModule().setInheritOutputDirs(true);
ideaModule.getModule().getScopes().get("COMPILE").get("plus").add(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES)); ideaModule.getModule().getScopes().get("COMPILE").get("plus").add(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES));
ideaModule.getModule().getScopes().get("COMPILE").get("plus").add(project.getConfigurations().getByName(Constants.COMPILE_MODS));
// ECLIPSE // ECLIPSE
EclipseModel eclipseModule = (EclipseModel) project.getExtensions().getByName("eclipse"); EclipseModel eclipseModule = (EclipseModel) project.getExtensions().getByName("eclipse");
eclipseModule.getClasspath().getPlusConfigurations().add(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES)); eclipseModule.getClasspath().getPlusConfigurations().add(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES));
eclipseModule.getClasspath().getPlusConfigurations().add(project.getConfigurations().getByName(Constants.COMPILE_MODS));
} }
/** /**
@ -164,7 +168,7 @@ public class AbstractPlugin implements Plugin<Project> {
LoomGradleExtension extension = project1.getExtensions().getByType(LoomGradleExtension.class); LoomGradleExtension extension = project1.getExtensions().getByType(LoomGradleExtension.class);
project1.getRepositories().flatDir(flatDirectoryArtifactRepository -> { project1.getRepositories().flatDir(flatDirectoryArtifactRepository -> {
flatDirectoryArtifactRepository.dir(extension.getFabricUserCache()); flatDirectoryArtifactRepository.dir(extension.getUserCache());
flatDirectoryArtifactRepository.setName("UserCacheFiles"); flatDirectoryArtifactRepository.setName("UserCacheFiles");
}); });
@ -179,8 +183,8 @@ public class AbstractPlugin implements Plugin<Project> {
}); });
project1.getRepositories().maven(mavenArtifactRepository -> { project1.getRepositories().maven(mavenArtifactRepository -> {
mavenArtifactRepository.setName("SpongePowered"); mavenArtifactRepository.setName("modmuss50");
mavenArtifactRepository.setUrl("http://repo.spongepowered.org/maven"); mavenArtifactRepository.setUrl("https://maven.modmuss50.me/");
}); });
project1.getRepositories().maven(mavenArtifactRepository -> { project1.getRepositories().maven(mavenArtifactRepository -> {
@ -209,14 +213,13 @@ public class AbstractPlugin implements Plugin<Project> {
} }
project1.getDependencies().add(Constants.CONFIG_MC_DEPENDENCIES, "net.minecraft:" + Constants.MINECRAFT_FINAL_JAR.get(extension).getName().replace(".jar", "")); project1.getDependencies().add(Constants.CONFIG_MC_DEPENDENCIES, "net.minecraft:" + Constants.MINECRAFT_FINAL_JAR.get(extension).getName().replace(".jar", ""));
if (extension.fabricVersion != null && !extension.fabricVersion.isEmpty()) { if (extension.isModWorkspace()) {
//only add this when not in a fabric dev env //only add this when not in a dev env
project1.getDependencies().add(Constants.CONFIG_MC_DEPENDENCIES, "net.fabricmc:fabric-base:" + extension.version + "-" + extension.fabricVersion + ":deobf"); project1.getDependencies().add(Constants.CONFIG_MC_DEPENDENCIES, "com.openmodloader:OpenModLoader:" + extension.getVersionString() +":deobf");
} }
project1.getDependencies().add(Constants.PROCESS_MODS_DEPENDENCIES, "net.fabricmc:fabric-base:16w38a-0.0.4-SNAPSHOT");
}); });
project.getTasks().getByName("build").doLast(task -> { project.getTasks().getByName("jar").doLast(task -> {
project.getLogger().lifecycle(":remapping mods"); project.getLogger().lifecycle(":remapping mods");
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class); LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
try { try {
@ -229,7 +232,7 @@ public class AbstractPlugin implements Plugin<Project> {
}); });
project.afterEvaluate(project12 -> { project.afterEvaluate(project12 -> {
project12.getTasks().getByName("idea").dependsOn(project12.getTasks().getByName("cleanIdea")).dependsOn(project12.getTasks().getByName("setupFabric")).dependsOn(project12.getTasks().getByName("extractNatives")); project12.getTasks().getByName("idea").dependsOn(project12.getTasks().getByName("cleanIdea")).dependsOn(project12.getTasks().getByName("setup")).dependsOn(project12.getTasks().getByName("extractNatives"));
project12.getTasks().getByName("idea").finalizedBy(project12.getTasks().getByName("genIdeaWorkspace")); project12.getTasks().getByName("idea").finalizedBy(project12.getTasks().getByName("genIdeaWorkspace"));
}); });
@ -242,17 +245,19 @@ public class AbstractPlugin implements Plugin<Project> {
Gson gson = new Gson(); Gson gson = new Gson();
try { try {
JsonElement jsonElement = gson.fromJson(new FileReader(modJson), JsonElement.class); JsonElement jsonElement = gson.fromJson(new FileReader(modJson), JsonElement.class);
JsonObject jsonObject = jsonElement.getAsJsonObject(); JsonArray jsonArray = jsonElement.getAsJsonArray();
if ((extension.version == null || extension.version.isEmpty()) && jsonObject.has("version")) { for (int i = 0; i < jsonArray.size(); i++) {
project.setVersion(jsonObject.get("version").getAsString()); JsonObject jsonObject = jsonArray.get(i).getAsJsonObject();
if ((extension.version == null || extension.version.isEmpty()) && jsonObject.has("version")) {
project.setVersion(jsonObject.get("version").getAsString());
}
if (jsonObject.has("group")) {
project.setGroup(jsonObject.get("group").getAsString());
}
if (jsonObject.has("description")) {
project.setDescription(jsonObject.get("description").getAsString());
}
} }
if (jsonObject.has("group")) {
project.setGroup(jsonObject.get("group").getAsString());
}
if (jsonObject.has("description")) {
project.setDescription(jsonObject.get("description").getAsString());
}
//TODO load deps
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
//This wont happen as we have checked for it //This wont happen as we have checked for it

View File

@ -31,8 +31,9 @@ import java.io.File;
public class LoomGradleExtension { public class LoomGradleExtension {
public String version; public String version;
public String runDir = "run"; public String runDir = "run";
public String fabricVersion; public String omlVersion;
public String pomfVersion; public String pomfVersion;
public boolean skipPrebake = false;
public boolean localMappings = false; public boolean localMappings = false;
//Not to be set in the build.gradle //Not to be set in the build.gradle
@ -40,17 +41,17 @@ public class LoomGradleExtension {
public String getVersionString() { public String getVersionString() {
if (isModWorkspace()) { if (isModWorkspace()) {
return version + "-" + fabricVersion; return version + "-" + omlVersion;
} }
return version; return version;
} }
public boolean isModWorkspace() { public boolean isModWorkspace() {
return fabricVersion != null && !fabricVersion.isEmpty(); return omlVersion != null && !omlVersion.isEmpty();
} }
public File getFabricUserCache() { public File getUserCache() {
File userCache = new File(project.getGradle().getGradleUserHomeDir(), "caches" + File.separator + "loom"); File userCache = new File(project.getGradle().getGradleUserHomeDir(), "caches" + File.separator + "fabric-loom");
if (!userCache.exists()) { if (!userCache.exists()) {
userCache.mkdirs(); userCache.mkdirs();
} }

View File

@ -35,16 +35,17 @@ public class LoomGradlePlugin extends AbstractPlugin {
makeTask("download", DownloadTask.class); makeTask("download", DownloadTask.class);
makeTask("mergeJars", MergeJarsTask.class).dependsOn("download"); makeTask("mergeJars", MergeJarsTask.class).dependsOn("download");
makeTask("mapJars", MapJarsTask.class).dependsOn("mergeJars"); makeTask("processMods", ProcessModsTask.class).dependsOn("mergeJars");
makeTask("processMods", ProcessModsTask.class).dependsOn("mapJars"); makeTask("mapJars", MapJarsTask.class).dependsOn("processMods");
makeTask("setupFabric", DefaultTask.class).dependsOn("processMods"); makeTask("finaliseJars", FinaliseJar.class).dependsOn("mapJars");
makeTask("setup", DefaultTask.class).dependsOn("finaliseJars").setGroup("openmodloader");
makeTask("extractNatives", ExtractNativesTask.class).dependsOn("download"); makeTask("extractNatives", ExtractNativesTask.class).dependsOn("download");
makeTask("genIdeaWorkspace", GenIdeaProjectTask.class).dependsOn("idea"); makeTask("genIdeaWorkspace", GenIdeaProjectTask.class).dependsOn("idea").setGroup("ide");
makeTask("vscode", GenVSCodeProjectTask.class).dependsOn("extractNatives"); makeTask("vscode", GenVSCodeProjectTask.class).dependsOn("extractNatives").setGroup("ide");
makeTask("runClient", RunClientTask.class).dependsOn("buildNeeded"); makeTask("runClient", RunClientTask.class).dependsOn("buildNeeded").setGroup("minecraft");
makeTask("runServer", RunServerTask.class).dependsOn("buildNeeded"); makeTask("runServer", RunServerTask.class).dependsOn("buildNeeded").setGroup("minecraft");
} }
} }

View File

@ -75,7 +75,7 @@ public class DownloadTask extends DefaultTask {
if (!Constants.MAPPINGS_ZIP.get(extension).exists() && extension.hasPomf()) { if (!Constants.MAPPINGS_ZIP.get(extension).exists() && extension.hasPomf()) {
this.getLogger().lifecycle(":downloading mappings"); this.getLogger().lifecycle(":downloading mappings");
try { try {
FileUtils.copyURLToFile(new URL("http://modmuss50.me:8080/job/FabricMC/job/pomf/job/" + extension.version + "/" + extension.pomfVersion + "/artifact/build/libs/pomf-enigma-" + extension.version + "." + extension.pomfVersion + ".zip"), Constants.MAPPINGS_ZIP.get(extension)); FileUtils.copyURLToFile(new URL("http://modmuss50.me:8080/job/OpenModLoader/job/pomf/job/" + extension.version + "/" + extension.pomfVersion + "/artifact/build/libs/pomf-enigma-" + extension.version + "." + extension.pomfVersion + ".zip"), Constants.MAPPINGS_ZIP.get(extension));
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Failed to download mappings", e); throw new RuntimeException("Failed to download mappings", e);
} }
@ -103,7 +103,7 @@ public class DownloadTask extends DefaultTask {
if (!Constants.MAPPINGS_TINY_GZ.get(extension).exists() && !extension.localMappings) { if (!Constants.MAPPINGS_TINY_GZ.get(extension).exists() && !extension.localMappings) {
getLogger().lifecycle(":downloading tiny mappings"); getLogger().lifecycle(":downloading tiny mappings");
try { try {
FileUtils.copyURLToFile(new URL("http://modmuss50.me:8080/job/FabricMC/job/pomf/job/" + extension.version + "/" + extension.pomfVersion + "/artifact/build/libs/pomf-tiny-" + extension.version + "." + extension.pomfVersion + ".gz"), Constants.MAPPINGS_TINY_GZ.get(extension)); FileUtils.copyURLToFile(new URL("http://modmuss50.me:8080/job/OpenModLoader/job/pomf/job/" + extension.version + "/" + extension.pomfVersion + "/artifact/build/libs/pomf-tiny-" + extension.version + "." + extension.pomfVersion + ".gz"), Constants.MAPPINGS_TINY_GZ.get(extension));
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Failed to download mappings", e); throw new RuntimeException("Failed to download mappings", e);
} }
@ -138,12 +138,9 @@ public class DownloadTask extends DefaultTask {
version.libraries.stream().filter(lib -> lib.natives != null).forEach(lib -> dependencyHandler.add(Constants.CONFIG_NATIVES, lib.getArtifactName())); version.libraries.stream().filter(lib -> lib.natives != null).forEach(lib -> dependencyHandler.add(Constants.CONFIG_NATIVES, lib.getArtifactName()));
} }
// Force add LaunchWrapper
dependencyHandler.add(Constants.CONFIG_MC_DEPENDENCIES, "net.minecraft:launchwrapper:1.12");
Version.AssetIndex assetIndex = version.assetIndex; Version.AssetIndex assetIndex = version.assetIndex;
File assets = new File(extension.getFabricUserCache(), "assets-" + extension.version); File assets = new File(extension.getUserCache(), "assets-" + extension.version);
if (!assets.exists()) { if (!assets.exists()) {
assets.mkdirs(); assets.mkdirs();
} }

View File

@ -0,0 +1,23 @@
package net.fabricmc.loom.task;
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.util.Constants;
import org.apache.commons.io.FileUtils;
import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.TaskAction;
import java.io.IOException;
public class FinaliseJar extends DefaultTask {
@TaskAction
public void finalisejar() throws IOException {
LoomGradleExtension extension = this.getProject().getExtensions().getByType(LoomGradleExtension.class);
if(Constants.MINECRAFT_FINAL_JAR.get(extension).exists()){
Constants.MINECRAFT_FINAL_JAR.get(extension).delete();
}
FileUtils.copyFile(Constants.MINECRAFT_MAPPED_JAR.get(extension), Constants.MINECRAFT_FINAL_JAR.get(extension));
}
}

View File

@ -135,22 +135,22 @@ public class GenIdeaProjectTask extends DefaultTask {
} }
IdeaRunConfig ideaClient = new IdeaRunConfig(); IdeaRunConfig ideaClient = new IdeaRunConfig();
ideaClient.mainClass = "net.minecraft.launchwrapper.Launch"; ideaClient.mainClass = "cpw.mods.modlauncher.Launcher";
ideaClient.projectName = project.getName(); ideaClient.projectName = project.getName();
ideaClient.configName = "Minecraft Client"; ideaClient.configName = "Minecraft Client";
ideaClient.runDir = "file://$PROJECT_DIR$/" + extension.runDir; ideaClient.runDir = "file://$PROJECT_DIR$/" + extension.runDir;
ideaClient.vmArgs = "-Djava.library.path=" + Constants.MINECRAFT_NATIVES.get(extension).getAbsolutePath() + " -Dfabric.development=true"; ideaClient.vmArgs = "-Djava.library.path=" + Constants.MINECRAFT_NATIVES.get(extension).getAbsolutePath() + " -Doml.development=true";
ideaClient.programArgs = "--tweakClass net.fabricmc.base.launch.FabricClientTweaker --assetIndex " + version.assetIndex.id + " --assetsDir " + new File(extension.getFabricUserCache(), "assets-" + extension.version).getAbsolutePath(); ideaClient.programArgs = "--launchTarget oml --accessToken not_a_real_token --version " + extension.version + " --assetIndex " + version.assetIndex.id + " --assetsDir " + new File(extension.getUserCache(), "assets-" + extension.version).getAbsolutePath();
runManager.appendChild(ideaClient.genRuns(runManager)); runManager.appendChild(ideaClient.genRuns(runManager));
IdeaRunConfig ideaServer = new IdeaRunConfig(); IdeaRunConfig ideaServer = new IdeaRunConfig();
ideaServer.mainClass = "net.minecraft.launchwrapper.Launch"; ideaServer.mainClass = "com.openmodloader.loader.launch.ServerLauncher";
ideaServer.projectName = project.getName(); ideaServer.projectName = project.getName();
ideaServer.configName = "Minecraft Server"; ideaServer.configName = "Minecraft Server";
ideaServer.runDir = "file://$PROJECT_DIR$/" + extension.runDir; ideaServer.runDir = "file://$PROJECT_DIR$/" + extension.runDir;
ideaServer.vmArgs = "-Dfabric.development=true"; ideaServer.vmArgs = "-Doml.development=true";
ideaServer.programArgs = "--tweakClass net.fabricmc.base.launch.FabricServerTweaker"; ideaServer.programArgs = "";
runManager.appendChild(ideaServer.genRuns(runManager)); runManager.appendChild(ideaServer.genRuns(runManager));

View File

@ -67,9 +67,9 @@ public class GenVSCodeProjectTask extends DefaultTask {
JsonObject jsonObject = new JsonObject(); JsonObject jsonObject = new JsonObject();
JsonArray jsonArray = new JsonArray(); JsonArray jsonArray = new JsonArray();
jsonArray.add("src/main/java"); jsonArray.add("src/main/java");
jsonArray.add("src/main/resorces"); jsonArray.add("src/main/resources");
jsonArray.add("src/test/java"); jsonArray.add("src/test/java");
jsonArray.add("src/test/resorces"); jsonArray.add("src/test/resources");
jsonObject.add("sourcePath", jsonArray); jsonObject.add("sourcePath", jsonArray);
JsonElement element = new JsonPrimitive(classPathFile.getName()); JsonElement element = new JsonPrimitive(classPathFile.getName());
jsonObject.add("classPathFile", element); jsonObject.add("classPathFile", element);

View File

@ -28,8 +28,9 @@ import cuchaz.enigma.Deobfuscator;
import cuchaz.enigma.TranslatingTypeLoader; import cuchaz.enigma.TranslatingTypeLoader;
import cuchaz.enigma.mapping.MappingsEnigmaReader; import cuchaz.enigma.mapping.MappingsEnigmaReader;
import cuchaz.enigma.mapping.TranslationDirection; import cuchaz.enigma.mapping.TranslationDirection;
import cuchaz.enigma.mapping.Translator;
import cuchaz.enigma.mapping.entry.ReferencedEntryPool;
import cuchaz.enigma.throwables.MappingParseException; import cuchaz.enigma.throwables.MappingParseException;
import javassist.CtClass;
import net.fabricmc.loom.LoomGradleExtension; import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.util.Constants; import net.fabricmc.loom.util.Constants;
import org.gradle.api.DefaultTask; import org.gradle.api.DefaultTask;
@ -55,7 +56,7 @@ public class MapJarsTask extends DefaultTask {
} }
if(!extension.hasPomf()){ if(!extension.hasPomf()){
this.getLogger().lifecycle("POMF version not set, skipping mapping!"); this.getLogger().lifecycle("POMF version not set, skipping mapping!");
FileUtils.copyFile(Constants.MINECRAFT_MERGED_JAR.get(extension), Constants.MINECRAFT_MAPPED_JAR.get(extension)); FileUtils.copyFile(Constants.MINECRAFT_MIXED_JAR.get(extension), Constants.MINECRAFT_MAPPED_JAR.get(extension));
return; return;
} }
if (!Constants.MAPPINGS_DIR.get(extension).exists() || extension.localMappings) { if (!Constants.MAPPINGS_DIR.get(extension).exists() || extension.localMappings) {
@ -65,7 +66,7 @@ public class MapJarsTask extends DefaultTask {
} }
this.getLogger().lifecycle(":remapping jar"); this.getLogger().lifecycle(":remapping jar");
deobfuscator = new Deobfuscator(new JarFile(Constants.MINECRAFT_MERGED_JAR.get(extension))); deobfuscator = new Deobfuscator(new JarFile(Constants.MINECRAFT_MIXED_JAR.get(extension)));
this.deobfuscator.setMappings(new MappingsEnigmaReader().read(Constants.MAPPINGS_DIR.get(extension))); this.deobfuscator.setMappings(new MappingsEnigmaReader().read(Constants.MAPPINGS_DIR.get(extension)));
writeJar(Constants.MINECRAFT_MAPPED_JAR.get(extension), new ProgressListener(), deobfuscator); writeJar(Constants.MINECRAFT_MAPPED_JAR.get(extension), new ProgressListener(), deobfuscator);
@ -76,7 +77,7 @@ public class MapJarsTask extends DefaultTask {
tempAssests.mkdir(); tempAssests.mkdir();
ZipUtil.unpack(Constants.MINECRAFT_CLIENT_JAR.get(extension), tempAssests, name -> { ZipUtil.unpack(Constants.MINECRAFT_CLIENT_JAR.get(extension), tempAssests, name -> {
if (name.startsWith("assets") || name.startsWith("log4j2.xml") || name.startsWith("pack.png")) { if (name.startsWith("assets") || name.startsWith("pack.mcmeta") || name.startsWith("data") || name.toLowerCase().startsWith("log4j2") || name.startsWith("pack.png")) {
return name; return name;
} else { } else {
return null; return null;
@ -93,22 +94,10 @@ public class MapJarsTask extends DefaultTask {
} }
public void writeJar(File out, Deobfuscator.ProgressListener progress, Deobfuscator deobfuscator) { public void writeJar(File out, Deobfuscator.ProgressListener progress, Deobfuscator deobfuscator) {
TranslatingTypeLoader loader = new TranslatingTypeLoader(deobfuscator.getJar(), deobfuscator.getJarIndex(), deobfuscator.getTranslator(TranslationDirection.Obfuscating), deobfuscator.getTranslator(TranslationDirection.Deobfuscating)); Translator obfuscationTranslator = deobfuscator.getTranslator(TranslationDirection.OBFUSCATING);
deobfuscator.transformJar(out, progress, new CustomClassTransformer(loader)); Translator deobfuscationTranslator = deobfuscator.getTranslator(TranslationDirection.DEOBFUSCATING);
} TranslatingTypeLoader loader = new TranslatingTypeLoader(deobfuscator.getJar(), deobfuscator.getJarIndex(), new ReferencedEntryPool(), obfuscationTranslator, deobfuscationTranslator);
deobfuscator.transformJar(out, progress, loader::transformInto);
private class CustomClassTransformer implements Deobfuscator.ClassTransformer {
TranslatingTypeLoader loader;
public CustomClassTransformer(TranslatingTypeLoader loader) {
this.loader = loader;
}
@Override
public CtClass transform(CtClass ctClass) throws Exception {
return loader.transformClass(ctClass);
}
} }
public static class ProgressListener implements Deobfuscator.ProgressListener { public static class ProgressListener implements Deobfuscator.ProgressListener {

View File

@ -26,7 +26,6 @@ package net.fabricmc.loom.task;
import net.fabricmc.loom.LoomGradleExtension; import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.util.Constants; import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.proccessing.PreBakeMixins;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.gradle.api.DefaultTask; import org.gradle.api.DefaultTask;
import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.Configuration;
@ -50,17 +49,17 @@ public class ProcessModsTask extends DefaultTask {
Configuration configuration = getProject().getConfigurations().getByName(Constants.COMPILE_MODS); Configuration configuration = getProject().getConfigurations().getByName(Constants.COMPILE_MODS);
List<File> mods = new ArrayList<>(); List<File> mods = new ArrayList<>();
for (ResolvedArtifact artifact : configuration.getResolvedConfiguration().getResolvedArtifacts()) { for (ResolvedArtifact artifact : configuration.getResolvedConfiguration().getResolvedArtifacts()) {
getProject().getLogger().lifecycle(":found mod to mix:" + artifact.getFile().getName()); //getProject().getLogger().lifecycle(":found mod to mix:" + artifact.getFile().getName());
mods.add(artifact.getFile()); mods.add(artifact.getFile());
} }
if (Constants.MINECRAFT_FINAL_JAR.get(extension).exists()) { if (Constants.MINECRAFT_FINAL_JAR.get(extension).exists()) {
Constants.MINECRAFT_FINAL_JAR.get(extension).delete(); Constants.MINECRAFT_FINAL_JAR.get(extension).delete();
} }
if (mods.size() == 0) { if (mods.size() == 0 || extension.skipPrebake) {
FileUtils.copyFile(Constants.MINECRAFT_MAPPED_JAR.get(extension), Constants.MINECRAFT_FINAL_JAR.get(extension)); FileUtils.copyFile(Constants.MINECRAFT_MERGED_JAR.get(extension), Constants.MINECRAFT_MIXED_JAR.get(extension));
} else { } else {
downloadRequiredDeps(extension); // downloadRequiredDeps(extension);
new PreBakeMixins().proccess(getProject(), extension, mods); throw new UnsupportedOperationException("Mixin prebake isnt done yet");
} }
} }

View File

@ -46,7 +46,7 @@ public class RunClientTask extends JavaExec {
try { try {
version = gson.fromJson(new FileReader(Constants.MINECRAFT_JSON.get(extension)), Version.class); version = gson.fromJson(new FileReader(Constants.MINECRAFT_JSON.get(extension)), Version.class);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); getLogger().error("Failed to retrieve version from minecraft json", e);
} }
List<String> libs = new ArrayList<>(); List<String> libs = new ArrayList<>();
@ -65,10 +65,15 @@ public class RunClientTask extends JavaExec {
libs.add(file.getAbsolutePath()); libs.add(file.getAbsolutePath());
} }
} }
libs.add(Constants.MINECRAFT_FINAL_JAR.get(extension).getAbsolutePath()); libs.add(Constants.MINECRAFT_CLIENT_JAR.get(extension).getAbsolutePath());
//Removes the deobf jars
libs.removeIf(s -> s.contains(Constants.MINECRAFT_FINAL_JAR.get(extension).getName()));
libs.removeIf(s -> s.contains(getProject().getName() + "-" + getProject().getVersion() + "-deobf.jar"));
classpath(libs); classpath(libs);
args("--tweakClass", "net.fabricmc.base.launch.FabricClientTweaker", "--assetIndex", version.assetIndex.id, "--assetsDir", new File(extension.getFabricUserCache(), "assets-" + extension.version).getAbsolutePath()); args("--launchTarget", "oml", "--accessToken", "NOT_A_TOKEN", "--version", extension.version, "--assetIndex", version.assetIndex.id, "--assetsDir", new File(extension.getUserCache(), "assets-" + extension.version).getAbsolutePath());
setWorkingDir(new File(getProject().getRootDir(), "run")); setWorkingDir(new File(getProject().getRootDir(), "run"));
@ -77,7 +82,7 @@ public class RunClientTask extends JavaExec {
@Override @Override
public String getMain() { public String getMain() {
return "net.minecraft.launchwrapper.Launch"; return "cpw.mods.modlauncher.Launcher";
} }
@Override @Override
@ -85,7 +90,7 @@ public class RunClientTask extends JavaExec {
LoomGradleExtension extension = this.getProject().getExtensions().getByType(LoomGradleExtension.class); LoomGradleExtension extension = this.getProject().getExtensions().getByType(LoomGradleExtension.class);
List<String> args = new ArrayList<>(); List<String> args = new ArrayList<>();
args.add("-Djava.library.path=" + Constants.MINECRAFT_NATIVES.get(extension).getAbsolutePath()); args.add("-Djava.library.path=" + Constants.MINECRAFT_NATIVES.get(extension).getAbsolutePath());
args.add("-Dfabric.development=true"); //args.add("-XstartOnFirstThread"); //Fixes lwjgl starting on an incorrect thread
return args; return args;
} }

View File

@ -65,8 +65,6 @@ public class RunServerTask extends JavaExec {
libs.add(Constants.MINECRAFT_FINAL_JAR.get(extension).getAbsolutePath()); libs.add(Constants.MINECRAFT_FINAL_JAR.get(extension).getAbsolutePath());
classpath(libs); classpath(libs);
args("--tweakClass", "net.fabricmc.base.launch.FabricServerTweaker");
setWorkingDir(new File(getProject().getRootDir(), "run")); setWorkingDir(new File(getProject().getRootDir(), "run"));
super.exec(); super.exec();
@ -74,7 +72,7 @@ public class RunServerTask extends JavaExec {
@Override @Override
public String getMain() { public String getMain() {
return "net.minecraft.launchwrapper.Launch"; return "com.openmodloader.loader.launch.ServerLauncher";
} }
@Override @Override

View File

@ -37,13 +37,14 @@ public class Constants {
public static final File WORKING_DIRECTORY = new File("."); public static final File WORKING_DIRECTORY = new File(".");
public static final File CACHE_FILES = new File(WORKING_DIRECTORY, ".gradle/minecraft"); public static final File CACHE_FILES = new File(WORKING_DIRECTORY, ".gradle/minecraft");
public static final IDelayed<File> MINECRAFT_CLIENT_JAR = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-client.jar")); public static final IDelayed<File> MINECRAFT_CLIENT_JAR = new DelayedFile(extension -> new File(extension.getUserCache(), extension.version + "-client.jar"));
public static final IDelayed<File> MINECRAFT_SERVER_JAR = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-server.jar")); public static final IDelayed<File> MINECRAFT_SERVER_JAR = new DelayedFile(extension -> new File(extension.getUserCache(), extension.version + "-server.jar"));
public static final IDelayed<File> MINECRAFT_MERGED_JAR = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-merged.jar")); public static final IDelayed<File> MINECRAFT_MERGED_JAR = new DelayedFile(extension -> new File(extension.getUserCache(), extension.version + "-merged.jar"));
public static final IDelayed<File> MINECRAFT_MAPPED_JAR = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.getVersionString() + "-mapped-" + extension.pomfVersion + ".jar")); public static final IDelayed<File> MINECRAFT_MIXED_JAR = new DelayedFile(extension -> new File(extension.getUserCache(), extension.version + "-mixed.jar"));
public static final IDelayed<File> MINECRAFT_FINAL_JAR = new DelayedFile(extension -> new File(CACHE_FILES, extension.getVersionString() + "-mixed-" + extension.pomfVersion + ".jar")); public static final IDelayed<File> MINECRAFT_MAPPED_JAR = new DelayedFile(extension -> new File(extension.getUserCache(), extension.version + "-mapped-" + extension.pomfVersion + ".jar"));
public static final IDelayed<File> MINECRAFT_FINAL_JAR = new DelayedFile(extension -> new File(CACHE_FILES, extension.version + "-final-" + extension.pomfVersion + ".jar"));
public static final IDelayed<File> POMF_DIR = new DelayedFile(extension -> new File(extension.getFabricUserCache(), "pomf")); public static final IDelayed<File> POMF_DIR = new DelayedFile(extension -> new File(extension.getUserCache(), "pomf"));
public static IDelayed<File> MAPPINGS_ZIP = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-enigma-" + extension.version + "." + extension.pomfVersion + ".zip")); public static IDelayed<File> MAPPINGS_ZIP = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-enigma-" + extension.version + "." + extension.pomfVersion + ".zip"));
public static final IDelayed<File> MAPPINGS_DIR = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-enigma-" + extension.version + "." + extension.pomfVersion + "")); public static final IDelayed<File> MAPPINGS_DIR = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-enigma-" + extension.version + "." + extension.pomfVersion + ""));
public static IDelayed<File> MAPPINGS_TINY_GZ = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-tiny-" + extension.version + "." + extension.pomfVersion + ".gz")); public static IDelayed<File> MAPPINGS_TINY_GZ = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-tiny-" + extension.version + "." + extension.pomfVersion + ".gz"));
@ -53,11 +54,11 @@ public class Constants {
public static final IDelayed<File> MAPPINGS_ZIP_LOCAL = new DelayedFile(extension -> new File(MAPPINGS_DIR_LOCAL.get(extension), "pomf-enigma-" + extension.version + ".zip")); public static final IDelayed<File> MAPPINGS_ZIP_LOCAL = new DelayedFile(extension -> new File(MAPPINGS_DIR_LOCAL.get(extension), "pomf-enigma-" + extension.version + ".zip"));
public static final IDelayed<File> MAPPINGS_TINY_GZ_LOCAL = new DelayedFile(extension -> new File(MAPPINGS_DIR_LOCAL.get(extension), "pomf-tiny-" + extension.version + ".gz")); public static final IDelayed<File> MAPPINGS_TINY_GZ_LOCAL = new DelayedFile(extension -> new File(MAPPINGS_DIR_LOCAL.get(extension), "pomf-tiny-" + extension.version + ".gz"));
public static final IDelayed<File> MINECRAFT_LIBS = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-libs")); public static final IDelayed<File> MINECRAFT_LIBS = new DelayedFile(extension -> new File(extension.getUserCache(), extension.version + "-libs"));
public static final IDelayed<File> MINECRAFT_NATIVES = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-natives")); public static final IDelayed<File> MINECRAFT_NATIVES = new DelayedFile(extension -> new File(extension.getUserCache(), extension.version + "-natives"));
public static final IDelayed<File> MINECRAFT_JSON = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-info.json")); public static final IDelayed<File> MINECRAFT_JSON = new DelayedFile(extension -> new File(extension.getUserCache(), extension.version + "-info.json"));
public static final IDelayed<File> VERSION_MANIFEST = new DelayedFile(extension -> new File(extension.getFabricUserCache(), "version_manifest.json")); public static final IDelayed<File> VERSION_MANIFEST = new DelayedFile(extension -> new File(extension.getUserCache(), "version_manifest.json"));
public static final String LIBRARIES_BASE = "https://libraries.minecraft.net/"; public static final String LIBRARIES_BASE = "https://libraries.minecraft.net/";
public static final String RESOURCES_BASE = "http://resources.download.minecraft.net/"; public static final String RESOURCES_BASE = "http://resources.download.minecraft.net/";

View File

@ -25,16 +25,21 @@
package net.fabricmc.loom.util; package net.fabricmc.loom.util;
import net.fabricmc.loom.LoomGradleExtension; import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.tinyremapper.OutputConsumerPath; import net.fabricmc.tinyremapper.*;
import net.fabricmc.tinyremapper.TinyRemapper; import org.apache.commons.io.FileUtils;
import net.fabricmc.tinyremapper.TinyUtils;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.MethodNode;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.*;
import java.util.List;
public class ModRemapper { public class ModRemapper {
@ -53,8 +58,11 @@ public class ModRemapper {
deobfJar.delete(); deobfJar.delete();
} }
FileUtils.touch(modJar); //Done to ensure that the file can be moved
//Move the pre existing mod jar to the deobf jar //Move the pre existing mod jar to the deobf jar
modJar.renameTo(deobfJar); if(!modJar.renameTo(deobfJar)){
throw new RuntimeException("Failed to rename " + modJar);
}
Path mappings = Constants.MAPPINGS_TINY.get(extension).toPath(); Path mappings = Constants.MAPPINGS_TINY.get(extension).toPath();
@ -65,7 +73,6 @@ public class ModRemapper {
classpathFiles.addAll(project.getConfigurations().getByName("compile").getFiles()); classpathFiles.addAll(project.getConfigurations().getByName("compile").getFiles());
classpathFiles.addAll(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES_CLIENT).getFiles()); classpathFiles.addAll(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES_CLIENT).getFiles());
classpathFiles.addAll(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES).getFiles()); classpathFiles.addAll(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES).getFiles());
classpathFiles.add(new File(Constants.MINECRAFT_FINAL_JAR.get(extension).getAbsolutePath()));//Seems to fix it not finding it
Path[] classpath = new Path[classpathFiles.size()]; Path[] classpath = new Path[classpathFiles.size()];
for (int i = 0; i < classpathFiles.size(); i++) { for (int i = 0; i < classpathFiles.size(); i++) {
@ -74,18 +81,155 @@ public class ModRemapper {
TinyRemapper remapper = TinyRemapper.newRemapper() TinyRemapper remapper = TinyRemapper.newRemapper()
.withMappings(TinyUtils.createTinyMappingProvider(mappings, fromM, toM)) .withMappings(TinyUtils.createTinyMappingProvider(mappings, fromM, toM))
.withRemapperExtension(new MixinRemapper())
.build(); .build();
OutputConsumerPath outputConsumer = new OutputConsumerPath(modJar.toPath()); try {
//Rebof the deobf jar OutputConsumerPath outputConsumer = new OutputConsumerPath(modJar.toPath());
outputConsumer.addNonClassFiles(deobfJar.toPath()); //Rebof the deobf jar
remapper.read(deobfJar.toPath()); outputConsumer.addNonClassFiles(deobfJar.toPath());
remapper.read(classpath); remapper.read(deobfJar.toPath());
remapper.apply(deobfJar.toPath(), outputConsumer); remapper.read(classpath);
outputConsumer.finish(); remapper.apply(deobfJar.toPath(), outputConsumer);
remapper.finish(); outputConsumer.finish();
remapper.finish();
} catch (Exception e){
remapper.finish();
throw new RuntimeException("Failed to remap jar", e);
}
if(!deobfJar.exists() || !modJar.exists()){
throw new RuntimeException("Failed to rebof jar");
}
//Add the deobf jar to be uploaded to maven //Add the deobf jar to be uploaded to maven
project.getArtifacts().add("archives", deobfJar); project.getArtifacts().add("archives", deobfJar);
} }
public static class MixinRemapper implements IRemapperExtension{
@Override
public byte[] handleUnmappedClass(byte[] inBytes, TinyRemapper remapper) {
//I know this isnt the fastest, but its the easiest
ClassNode classNode = readClassFromBytes(inBytes);
if(isMixin(classNode)){
String target = getMixinTarget(classNode);
System.out.println("Remapping mixin (" + classNode.name + ") targeting: " + target);
for(MethodNode methodNode : classNode.methods){
if(needsTargetMap(methodNode.visibleAnnotations)){
methodNode.visibleAnnotations.add(createTargetMap(methodNode, target, remapper));
}
}
for(FieldNode fieldNode : classNode.fields){
if(needsTargetMap(fieldNode.visibleAnnotations)){
//fieldNode.visibleAnnotations.add(createTargetMap(fieldNode));
}
}
return writeClassToBytes(classNode);
}
return inBytes;
}
private AnnotationNode createTargetMap(MethodNode methodNode, String targetClass, TinyRemapper remapper){
AnnotationNode targetMapNode = new AnnotationNode("Lme/modmuss50/fusion/api/TargetMap;");
String deobfTarget = methodNode.name + methodNode.desc;
if(getRewriteTarget(methodNode).isPresent()){
deobfTarget = getRewriteTarget(methodNode).get();
}
if(deobfTarget.equals("<init>")){
//No need to handle constructors, may need to do something about the desc but we will see
return targetMapNode;
}
String oldName = deobfTarget.substring(0, deobfTarget.indexOf("("));
String oldDesc = deobfTarget.substring(deobfTarget.lastIndexOf("("));
String newName = remapper.remapper.mapMethodName(targetClass.replaceAll("\\.", "/"), oldName, oldDesc);
String newDesc = remapper.remapper.mapDesc(oldDesc);
System.out.println(oldName + oldDesc + " -> " + newName + newDesc);
targetMapNode.visit("value", newName + newDesc);
return targetMapNode;
}
private boolean isMixin(ClassNode classNode){
if(classNode.visibleAnnotations == null){
return false;
}
for(AnnotationNode annotation : classNode.visibleAnnotations){
if(annotation.desc.equals("Lme/modmuss50/fusion/api/Mixin;")){
return true;
}
}
return false;
}
private String getMixinTarget(ClassNode classNode){
if(classNode.visibleAnnotations == null){
throw new RuntimeException(classNode.name + " is not a mixin!");
}
for(AnnotationNode annotation : classNode.visibleAnnotations){
if(annotation.desc.equals("Lme/modmuss50/fusion/api/Mixin;")){
for (int i = 0; i < annotation.values.size(); i++) {
Object value = annotation.values.get(i);
if(value instanceof String && value.toString().equals("value")){
Type target = (Type) annotation.values.get(i + 1);
return target.getClassName();
}
}
}
}
throw new RuntimeException(classNode.name + " is not a valid mixin!");
}
private Optional<String> getRewriteTarget(MethodNode methodNode){
if(methodNode.visibleAnnotations == null){
return Optional.empty();
}
for(AnnotationNode annotation : methodNode.visibleAnnotations){
if(annotation.desc.equals("Lme/modmuss50/fusion/api/Rewrite;")){
for (int i = 0; i < annotation.values.size(); i++) {
Object value = annotation.values.get(i);
if(value instanceof String && value.toString().equals("target")){
return Optional.of((String) annotation.values.get(i + 1));
}
}
}
}
return Optional.empty();
}
private boolean needsTargetMap(List<AnnotationNode> annotationNodes){
if(annotationNodes == null){
return false;
}
for(AnnotationNode annotation : annotationNodes){
if(annotation.desc.equals("Lme/modmuss50/fusion/api/Rewrite;")){
return true;
}
if(annotation.desc.equals("Lme/modmuss50/fusion/api/Inject;")){
return true;
}
}
return false;
}
private static ClassNode readClassFromBytes(byte[] bytes) {
ClassNode classNode = new org.objectweb.asm.tree.ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
return classNode;
}
private static byte[] writeClassToBytes(ClassNode classNode) {
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
classNode.accept(writer);
return writer.toByteArray();
}
}
} }

View File

@ -1,53 +0,0 @@
/*
* This file is part of fabric-loom, licensed under the MIT License (MIT).
*
* Copyright (c) 2016 FabricMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.fabricmc.loom.util.proccessing;
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.task.ProcessModsTask;
import net.fabricmc.loom.util.Constants;
import org.gradle.api.Project;
import java.io.File;
import java.util.List;
public class PreBakeMixins {
public void proccess(Project project, LoomGradleExtension extension, List<File> mods) {
project.getLogger().lifecycle(":Found " + mods.size() + " mods to prebake");
String[] args = new String[mods.size() + 4];
args[0] = "-m";
args[1] = Constants.MAPPINGS_TINY.get(extension).getAbsolutePath();
args[2] = Constants.MINECRAFT_MAPPED_JAR.get(extension).getAbsolutePath();
args[3] = Constants.MINECRAFT_FINAL_JAR.get(extension).getAbsolutePath();
for (int i = 0; i < mods.size(); i++) {
args[i + 4] = mods.get(i).getAbsolutePath();
}
project.getLogger().lifecycle(":preBaking mixins");
ProcessModsTask.addFile(Constants.MINECRAFT_MAPPED_JAR.get(extension), this);
//LogManager.getFormatterLogger("test");
// MixinPrebaker.main(args);
}
}

View File

@ -1 +0,0 @@
net.fabricmc.loom.mixin.ObfuscationServiceFabric