Allow specifying natives directory with the `fabric.loom.natives.dir` gradle property.

Note this is designed to allow easy usage of custom natives, thus will not populate the directory with the default natives.
dev/0.11
modmuss50 2020-12-02 20:18:12 +00:00
parent 98725f9400
commit dd68c84226
2 changed files with 18 additions and 0 deletions

View File

@ -236,6 +236,12 @@ public class LoomGradleExtension {
} }
public File getNativesDirectory() { public File getNativesDirectory() {
Object customNativesDir = project.getProperties().get("fabric.loom.natives.dir");
if (customNativesDir != null) {
return new File((String) customNativesDir);
}
File natives = new File(getUserCache(), "natives/" + getMinecraftProvider().getMinecraftVersion()); File natives = new File(getUserCache(), "natives/" + getMinecraftProvider().getMinecraftVersion());
if (!natives.exists()) { if (!natives.exists()) {
@ -245,6 +251,10 @@ public class LoomGradleExtension {
return natives; return natives;
} }
public boolean hasCustomNatives() {
return project.getProperties().get("fabric.loom.natives.dir") != null;
}
public File getDevLauncherConfig() { public File getDevLauncherConfig() {
return new File(getProjectPersistentCache(), "launch.cfg"); return new File(getProjectPersistentCache(), "launch.cfg");
} }

View File

@ -45,6 +45,14 @@ public class MinecraftNativesProvider {
File nativesDir = extension.getNativesDirectory(); File nativesDir = extension.getNativesDirectory();
File jarStore = extension.getNativesJarStore(); File jarStore = extension.getNativesJarStore();
if (extension.hasCustomNatives()) {
if (!nativesDir.exists()) {
throw new RuntimeException("Could no find custom natives directory at " + nativesDir.getAbsolutePath());
}
return;
}
for (MinecraftVersionInfo.Library library : versionInfo.libraries) { for (MinecraftVersionInfo.Library library : versionInfo.libraries) {
File libJarFile = library.getFile(jarStore); File libJarFile = library.getFile(jarStore);