Skip to content

Commit

Permalink
Replace Union Relauncher with Bootstrap Dev
Browse files Browse the repository at this point in the history
  • Loading branch information
shedaniel committed Jul 26, 2024
1 parent d30d38e commit 642d2a1
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 19 deletions.
2 changes: 0 additions & 2 deletions gradle/runtime.libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ access-transformers-new = "8.0.5"
access-transformers-neo = "10.0.2"
unprotect = "1.2.0"
asm = "9.7"
union-relauncher = "1.1.1"
access-transformers-log4j = "2.17.1"

[libraries]
Expand All @@ -45,5 +44,4 @@ access-transformers-new = { module = "net.minecraftforge:accesstransformers", ve
access-transformers-neo = { module = "net.neoforged.accesstransformers:at-cli", version.ref = "access-transformers-neo" }
unprotect = { module = "io.github.juuxel:unprotect", version.ref = "unprotect" }
asm = { module = "org.ow2.asm:asm", version.ref = "asm" }
union-relauncher = { module = "io.github.juuxel:union-relauncher", version.ref = "union-relauncher" }
access-transformers-log4j-bom = { module = "org.apache.logging.log4j:log4j-bom", version.ref = "access-transformers-log4j" }
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ public static void provide(MappingConfiguration mappingConfiguration, Project pr
}
}

if (lib.startsWith("net.minecraftforge:bootstrap:")) {
if (extension.isForge() && extension.getForgeProvider().getVersion().getMajorVersion() >= Constants.Forge.MIN_BOOTSTRAP_DEV_VERSION) {
String version = lib.substring(lib.lastIndexOf(":"));
dependencies.add(project.getDependencies().create("net.minecraftforge:bootstrap-dev" + version));
}
}

if (dep == null) {
dep = lib;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.configuration.DependencyInfo;
import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.LoomVersions;
import net.fabricmc.loom.util.ModPlatform;

public class ForgeProvider extends DependencyProvider {
Expand All @@ -50,10 +49,6 @@ public void provide(DependencyInfo dependency) throws Exception {
version = new ForgeVersion(dependency.getResolvedVersion());
addDependency(dependency.getDepString() + ":userdev", Constants.Configurations.FORGE_USERDEV);
addDependency(dependency.getDepString() + ":installer", Constants.Configurations.FORGE_INSTALLER);

if (getExtension().isForge() && version.getMajorVersion() >= Constants.Forge.MIN_UNION_RELAUNCHER_VERSION) {
addDependency(LoomVersions.UNION_RELAUNCHER.mavenNotation(), Constants.Configurations.FORGE_EXTRA);
}
}

public ForgeVersion getVersion() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,6 @@ public void applyTo(RunConfigSettings settings, ConfigValue.Resolver configValue

// Add MOD_CLASSES, this is something that ForgeGradle does
settings.getEnvironmentVariables().computeIfAbsent("MOD_CLASSES", $ -> ConfigValue.of("{source_roots}").resolve(configValueResolver));

final ForgeProvider forgeProvider = settings.getExtension().getForgeProvider();

if (settings.getExtension().isForge() && forgeProvider.getVersion().getMajorVersion() >= Constants.Forge.MIN_UNION_RELAUNCHER_VERSION) {
settings.defaultMainClass(Constants.Forge.UNION_RELAUNCHER_MAIN_CLASS);
settings.property(Constants.Forge.UNION_RELAUNCHER_MAIN_CLASS_PROPERTY, main);
}
}

public Resolved resolve(ConfigValue.Resolver configValueResolver) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ private String resolve(@Nullable RunConfigSettings runConfig, ConfigValue.Variab
// Use a set-valued multimap for deduplicating paths.
Multimap<String, String> modClasses = MultimapBuilder.hashKeys().linkedHashSetValues().build();
NamedDomainObjectContainer<ModSettings> mods = extension.getMods();
// Forge 49+ bootstrap-dev uses ; as a separator, instead of File.pathSeparator
String separator = extension.getForgeProvider().getVersion().getMajorVersion() >= Constants.Forge.MIN_BOOTSTRAP_DEV_VERSION ? ";" : File.pathSeparator;

if (runConfig != null && !runConfig.getMods().isEmpty()) {
mods = runConfig.getMods();
Expand All @@ -147,7 +149,7 @@ private String resolve(@Nullable RunConfigSettings runConfig, ConfigValue.Variab

string = modClasses.entries().stream()
.map(entry -> entry.getKey() + "%%" + entry.getValue())
.collect(Collectors.joining(File.pathSeparator));
.collect(Collectors.joining(separator));
} else if (key.equals("mcp_mappings")) {
string = "loom.stub";
} else if (json.has(key)) {
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/net/fabricmc/loom/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,9 @@ public static final class Forge {
public static final String MIXIN_CONFIGS_MANIFEST_KEY = "MixinConfigs";

/**
* The minimum Forge version that needs Union Relauncher to use {@code MOD_CLASSES}.
* The minimum Forge version that needs bootstrap-dev to use {@code MOD_CLASSES}.
*/
public static final int MIN_UNION_RELAUNCHER_VERSION = 49;
public static final String UNION_RELAUNCHER_MAIN_CLASS = "juuxel.unionrelauncher.UnionRelauncher";
public static final String UNION_RELAUNCHER_MAIN_CLASS_PROPERTY = "unionRelauncher.mainClass";
public static final int MIN_BOOTSTRAP_DEV_VERSION = 49;

/**
* The minimum version of Forge that uses "mojang" as the namespace in production.
Expand Down

0 comments on commit 642d2a1

Please sign in to comment.