Skip to content

Running game with custom mappings and namespace outside fabric-loom. #1057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
import net.fabricmc.tinyremapper.TinyUtils;

public final class GameProviderHelper {
private static final boolean DEVELOPMENT_DEOBF_GAME_JAR = System.getProperty(SystemProperties.DEVELOPMENT_DEOBF_GAME_JAR) != null;

private GameProviderHelper() { }

public static Path getCommonGameJar() {
Expand Down Expand Up @@ -163,7 +165,7 @@ public static Map<String, Path> deobfuscate(Map<String, Path> inputFileMap, Stri
public static Map<String, Path> deobfuscate(Map<String, Path> inputFileMap, String gameId, String gameVersion, Path gameDir, FabricLauncher launcher, String sourceNamespace) {
Log.debug(LogCategory.GAME_REMAP, "Requesting deobfuscation of %s", inputFileMap);

if (launcher.isDevelopment()) { // in-dev is already deobfuscated
if (launcher.isDevelopment() && !DEVELOPMENT_DEOBF_GAME_JAR) { // in-dev is already deobfuscated
return inputFileMap;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.JarURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
Expand All @@ -42,6 +44,8 @@
import net.fabricmc.mappingio.tree.MemoryMappingTree;

public final class MappingConfiguration {
private static final String MAPPINGS_PATH = System.getProperty(SystemProperties.MAPPINGS_PATH, null);
private static final String TARGET_NAMESPACE = System.getProperty(SystemProperties.TARGET_NAMESPACE, null);
private static final boolean FIX_PACKAGE_ACCESS = System.getProperty(SystemProperties.FIX_PACKAGE_ACCESS) != null;

private boolean initializedMetadata;
Expand Down Expand Up @@ -91,6 +95,10 @@ public MappingTree getMappings() {
}

public String getTargetNamespace() {
if (TARGET_NAMESPACE != null) {
return TARGET_NAMESPACE;
}

return FabricLauncherBase.getLauncher().isDevelopment() ? "named" : "intermediary";
}

Expand Down Expand Up @@ -178,7 +186,17 @@ private void initializeMappings() {

@Nullable
private URLConnection openMappings() {
URL url = MappingConfiguration.class.getClassLoader().getResource("mappings/mappings.tiny");
URL url;

if (MAPPINGS_PATH != null) {
try {
url = new URL(MAPPINGS_PATH);
} catch (MalformedURLException ex) {
url = null;
}
} else {
url = MappingConfiguration.class.getClassLoader().getResource("mappings/mappings.tiny");
}

if (url != null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
public final class SystemProperties {
// whether fabric loader is running in a development environment / mode, affects class path mod discovery, remapping, logging, ...
public static final String DEVELOPMENT = "fabric.development";
// runtime deobf game jar although it is in development
public static final String DEVELOPMENT_DEOBF_GAME_JAR = "fabric.development.deobfGameJar";
public static final String SIDE = "fabric.side";
// skips the embedded MC game provider, letting ServiceLoader-provided ones take over
public static final String SKIP_MC_PROVIDER = "fabric.skipMcProvider";
Expand All @@ -42,6 +44,10 @@ public final class SystemProperties {
public static final String REMAP_CLASSPATH_FILE = "fabric.remapClasspathFile";
// class path groups to map multiple class path entries to a mod (paths separated by path separator, groups by double path separator)
public static final String PATH_GROUPS = "fabric.classPathGroups";
// direct use a tiny file as mappings for mapping configuration
public static final String MAPPINGS_PATH = "fabric.mappingsPath";
// define the target namespace for mapping configuration
public static final String TARGET_NAMESPACE = "fabric.targetNamespace";
// enable the fixing of package access errors in the game jar(s)
public static final String FIX_PACKAGE_ACCESS = "fabric.fixPackageAccess";
// system level libraries, matching code sources will not be assumed to be part of the game or mods and remain on the system class path (paths separated by path separator)
Expand Down